[SOLVED] Problem running exported jar on linux


I exported my sketch for linux successfully, but I can’t find a way to run it now.
I got 4 folders after the export, for different architectures, the one interesting me being application.linux64. It contains a folder ‘lib’, a folder ‘source’ and a shell script ‘MySketch’.
Here is what I tried so far :

  • Double click on ‘MySketch’ : nothing happens.
  • Running java -cp MySketch.jar:core.jar MySketch in a terminal from the ‘lib’ folder, as explained by PhiLho here : I get the following output
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 10
	at java.lang.String.checkBoundsBeginEnd(java.base@9-internal/String.java:3119)
	at java.lang.String.substring(java.base@9-internal/String.java:1907)
	at processing.core.PApplet.<clinit>(PApplet.java:120)
  • Extracting core.jar and MySketch.jar in a folder then zip it and launch it as a .jar (still explained by PhiLho) : got the same output

Can you help me with this ? Thanks

1 Like

Did you try in a console typing ./mySketch?

make sure it is marked as executable.


Are you sure your code runs properly?

…looks to me like an error in your code? I might be wrong though.

Looks like you have Java 9 or 10 as your default Java. Processing will only run on 8. Which OS are you using?

@kfrajer ./mySketch throws the same exception.

@MxFxM No problem in the code when ran from the IDE.

@neilcsmith Indeed I am using openjdk version “9-internal”, on Ubuntu 16.04 and Processing 3.3.7. Is there a simple way to run the sketch with java 8 ? I am not sure I want to go into this kind of settings on my computer.

I exported the sketch with java embedded and it works perfectly !

Either uninstall OpenJDK 9 and replace with OpenJDK 8, or install both and use

sudo update-alternatives --config java

to switch between which one is used as default.

On Ubuntu 16.04 I would just use OpenJDK 8. OpenJDK 9 tends to break lots of stuff and isn’t really supported upstream any more. Once you upgrade to Ubuntu 18.04 you’ll have the option of OpenJDK 10 going to OpenJDK 11, which will be the next Java LTS (not that that means very much). That still won’t work with Processing … yet!


I installed OpenJDK 8 and used
sudo update-alternatives --config java
The sketch exported without java embedded now works !

Thanks you for your help :slight_smile:

1 Like