So I have created a java application in eclipse and I use javafx, and then exported it in a runnable jar file. However, when I run my .jar file it gives the error of not finding my images. It works perfectly fine when I run inside eclipse.
In UserPane I have a function that takes the image name as "title" and returns the imageview:
InputStream is=null;
try {
is=new FileInputStream("./Images/"+title+".jpg");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Image img=new Image(is);
ImageView imgview=new ImageView();
imgview.setImage(img);
imgview.setFitHeight(300);
imgview.setFitWidth(300);
return imgview;
I have tried some solutions, but it won't run in eclipse. I need it to run in eclipse and from the .jar. I need it to be set in the imageview please.
Update: I did not use any of the suggestions mentioned because none of them were helpful, none of them worked. What worked for me is moving my .jar in the same folder where my images folder is, while still keeping the above code.
Thank you