I have an executable jar file compiled with Java 8 and containing a JavaFX application called app.jar
.
When I had Java 8 installed I could run it simply with java -jar app.jar
.
Now I only have Java 11 installed and running the command above generates the following error:
Error: Could not find or load main class <...>
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application
because Java 11 no longer includes JavaFX.
So I looked into installing JavaFX. openjfx.org provides JavaFx in two forms: an SDK and in JMOD files.
I figure I don't need the SDK because I am not creating a JavaFX but merely running one. This leaves the JMOD files as the remaining options.
However, the Oracle documentation on JMODs says: "The JMOD file format let’s you aggregate files other than .class files, metadata, and resources. This format is transportable but not executable, which means that you can use it during compile time or link time but not at run time," so it does not seem like they are going to help me running an application.
Questions:
- How can I run
app.jar
as defined above with a Java 11 runtime? - Is there any documentation explaining how to do this and, if so, where?