JavaFX .jar works on Windows and OSX but not on Linux


I’m trying to make a cross-platform JavaFX application, and it works fine on Windows and OSX machines, but not on Linux.

When I try to run it on a Linux machine using java -jar app.jar, this is what I get:

Error: Could not find or load main class app.Main

But the class app.Main is in the .jar, as shown by ‘jar tf app.jar’:


I tried specifying the main class using java -cp app.jar app.Main but I got the same error message.

The .jar was built in Intellij IDEA, using basic JavaFX configuration.

Any help?


So, turns out the problem was that the JRE on the Linux machine was OpenJDK, which does not come with JavaFX, as noted by James_D and jewelsea

After installing the oracle JRE 8, it worked fine

Answered By – Matheus Valin

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published