Question

Hello i am trying to add a texture to a game i have just started to create and i keep getting errors and i was just wondering if someone could help. The errors keep point to this .java file and the code is as follows. package com.mime.minefront.graphics;

import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

public class Texture {

public static Render floor = loadBitmap("\textures.textures/floor.png");

public static Render loadBitmap(String fileName) {
    try {
        BufferedImage image = ImageIO.read(Texture.class.getResource(fileName));
        int width = image.getWidth();
        int height = image.getHeight();
        Render result = new Render(width, height);
        image.getRGB(0, 0, width, height, result.pixels, 0, width);
        return result;
    } catch (Exception e) {
        System.out.println("CRASH!");
        throw new RuntimeException(e);

    }
}

}

And the error list is.

 Exception in thread "Thread-2" java.lang.ExceptionInInitializerError
at com.mime.minefront.graphics.Render3D.floor(Render3D.java:42)
at com.mime.minefront.graphics.Screen.render(Screen.java:28)
at com.mime.minefront.Display.render(Display.java:144)
at com.mime.minefront.Display.run(Display.java:112)
at java.lang.Thread.run(Thread.java:724)
 Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: input ==               null!
at com.mime.minefront.graphics.Texture.loadBitmap(Texture.java:20)
at com.mime.minefront.graphics.Texture.<clinit>(Texture.java:8)
... 5 more
Caused by: java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(ImageIO.java:1388)
at com.mime.minefront.graphics.Texture.loadBitmap(Texture.java:12)
... 6 more

No correct solution

OTHER TIPS

The resource that you are specifying "\textures.textures/floor.png" cannot be found located by JVM.

The resource path should not use "\", but "/" instead if absolute path is desired.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top