Issue
I'm trying to run an application using the command prompt. It's built in Eclipse, using JavaFx. It's a digital diary program that I've been writing for a while and would like to send it to some friends. It is exported with packaged libraries as a runnable jar file.
java -jar -Djavafx.verbose=true main.jar --module-path /users/home/javafx-sdk-11.0.2/lib --add-modules javafx.controls,javafx.fxml
to run it.
I've traced the errors (through use of -Djavafx.verbose=true
) to java.lang.UnsatisfiedLinkError.
One of them is as follows:
WARNING: java.lang.UnsatisfiedLinkError: Invalid URL for class: jar:rsrc:javafx.graphics.jar!/com/sun/glass/utils/NativeLibLoader.class
What's causing this error?
EDIT after moving the --add-modules before main.jar, I get some new errors.
Exception in thread "main" java.lang.ExceptionInInitializerError
...
Caused by: java.lang.IllegalStateException: This operation is permitted on the event thread only; currentThread = main
...
Solution
When specifying arguments for the java virtual machine being run with a -jar
command, these arguments need to go before the jar file name in the command line.
Do not use this
It will treat the module arguments as program arguments rather than VM arguments:
java -jar -Djavafx.verbose=true main.jar --module-path /users/home/javafx-sdk-11.0.2/lib --add-modules javafx.controls,javafx.fxml
Instead, use this
java --module-path /users/home/javafx-sdk-11.0.2/lib --add-modules javafx.controls,javafx.fxml -Djavafx.verbose=true -jar main.jar
Answered By - jewelsea
Answer Checked By - Marie Seifert (JavaFixing Admin)