i made a game with awt and made a jar out of it . but when i run it by right clicking it it doesnt load the assets ( assets are on the jar file) But then i run it with terminal it loads the assets !
i'm using MacOS Monterey and Java 17
i used this code to get a image :
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public class Image {
public BufferedImage image;
public Image(String Path){
BufferedImage img = null;
try {
img = ImageIO.read(new File(Path));
} catch (IOException e) {
}
this.image = img;
}
public static void drawImage(Graphics2D g,Image image,int x,int y,int w,int h){
g.drawImage(image.image,x,y,w,h,null);
}
}
and i called them like this:
Image image = new Image("Data/image.PNG");
// And in my draw Method:
public void draw(Graphics2D g){
Image.drawImage(g,image,0,0,32,32);
}
the game with double clicking the jar on mac game with double clicking(img)
and the game with opening the game with : (java -jar game.jar) game with running on terminal(img)