B4J Question How to execute JAR file with JAVA 11? (JavaFX Components missing)

jmon

Well-Known Member
Licensed User
Longtime User
If you used to execute jar files in command line this way before:
java -jar MyProgram.jar
Or double-clicking on the JAR file, you will probably end up having this error showing up:
Error: JavaFX runtime components are missing, and are required to run this application

... so here is the fix:
  1. Create a .txt file
  2. copy paste this into this file:
    1. B4X:
      set JAVADIR="C:\java\jdk-11.0.1\jdk-11.0.1"
      set JARFILE="C:\temp\MyProgram.jar"
      set STARTDIR="C:\temp"
      
      cd %STARTDIR%
      %JAVADIR%\bin\java.exe --module-path %JAVADIR%\javafx\lib --add-modules=javafx.controls,javafx.fxml,javafx.web -jar %JARFILE%
      
      PAUSE
  3. Modify JAVADIR, STARTDIR and JARFILE variables with the location to your JDK and the location of the jar file you want to execute.
  4. Save the txt file
  5. Rename the extension of the ".txt" file to ".bat"
  6. Double click the BAT file.
 
Top