I have tried to export my processing applet to a runnable jar file from eclipse (which I am using to code it) and it exports successfully but when opened just causes a blank (grey) screen. If I run it with command prompt I get this error:
java.lang.NullPointerException: Cannot invoke "String.contains(java.lang.CharSequence)" because "jarPath" is null
When I extracted the jar sample the folders and directories seem to be incorrect too.
This made it easier to debug java classpath issues (-cp
flag when running from command line) and native library paths(-D.java.library.path
command line flag).
If you're using java packages remember to specify them in PApplet.main()
:
public static void main(String[] args) {
PApplet.main(ShooterGame.class.getCannonicalName());
}
The above is useful only if you can't execute the jar files due to missing libraries (class not found, missing native libraries, etc.)
Regarding loading external assets, as Shivoum B mentions, you can make use of dataPath()
but also sketchPath().(See this similar answer).
Without seeing the path to the loadImage()
call you're making I can only make assumptions, but you might be able to get away with something like this in ShooterGame.java:
loadImage(sketchPath("data" File.separator "yourImageName.png");
(Off-topic, if I read this correctly you're trying to load images in draw()
?
I'd recommend loading all assets in setup()
once instead of multiple times in draw()
. A special case might be with the loading large assets that take time and using P2D
or P3D
where the OpenGL context setup might time out (in which you can load in draw()
but should use a "debouncing" boolean to ensure assets are loaded only once)