java - There is a Jpanel that opens when running from eclipse and after exporting as executable jar it won't open -
i'm creating game called lines of actions , facing problem here when exporting executable jar file
when press button "two players" panel should shown
and show when run eclipse doesn't when run executable jar file
note: images in images source folder , i'm using method image:
private imageicon image(string s) { return new imageicon(getclass().getclassloader().getresource(s)); }
and when creating jlable :
new jlabel(image("example.png"));
while project this:
run jar console java -jar filename.jar
. have null on of resources (images).
you can see errors , warnings in console, clicking jar won't let that.
to comment below: try loading image jpanel same way loading main background images (for title/options menu), know work already. need inputstream
loading resources within executable .jar
.
getresourceasstream want use loading resources within executables. practice use this, within ide ( eclipse) exporting easier.
to question edit: getresource
returns url
happens null
in case. try doing image("example.png"));
. wrote .ong
fileextension, if meant .png
change , code should work :)
if didn't mean write .ong
try adding backslash filename so: image("/example.png");
can read in link above why.
Comments
Post a Comment