3

Install4J VM parameters for JAVAFX seem to not pass to the JVM

With a non-modularized application which depends on JAVAFX the suggested approach is adding

"--module-path ${PATH_TO_FX} --add-modules ALL-MODULE-PATH"

or specific modules to the java command line. This works fine. However, when creating an installer with install4j and including these in the Java Invocation VM parameters field for the installer, the application does not start and reports error:java.lang.RuntimeException: No toolkit found

This is a new behavior since updating to Java 11+ (given modularization and JavaFX separation). For other reasons we have no desire to modularize our whole application yet. The code works fine in Eclipse and with by hand command line or bat start up. We have also tried to include a VMoptions file with these arguments to no avail.

Currently running AdoptOpenJDK-13, JAVAFX-13, and Install4J 7.0.12

--module-path ${PATH_TO_FX} --add-modules ALL-MODULE-PATH

How can we create the install4j installer that has the same start up behavior as our command line -- recognizing javafx -- while still not modularizing the full application?

The command line arguments are:

"--module-path ${PATH_TO_FX} --add-modules ALL-MODULE-PATH"

The extended error when running the install4j launcher is:

java.lang.RuntimeException: No toolkit found
    at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:272)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
    at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
    at java.base/java.lang.Thread.run(Thread.java:830)
brian
  • 10,619
  • 4
  • 21
  • 79
BRM
  • 76
  • 1
  • 2
  • Using the `--module-path` VM parameter directly does not work with generated launchers in install4j. Have you tried to configure a mixed class and module path for the launcher? On the "Java invocation" step of the launcher wizard, use the "Class path" and "Module path" radio buttons to switch between the path configurations. – Ingo Kegel Nov 03 '19 at 21:18
  • We have tried, but the shift to a modular or mixed modular approach will require some other heavy lifting an refactoring; thus we want to stick for this release to non modular. We are confused though; how is the VM parameter not recognized? This would seem to be a regular or straighforward role of the installer. Please help! – BRM Dec 07 '19 at 21:15
  • Launchers generated by install4j do not use the java launcher executable which interprets the class and module path command line arguments. However, the class and module path configuration in install4j are equivalent to the `-classpath` and `--module-path` command line arguments, so I fail to see what the problem is. – Ingo Kegel Dec 08 '19 at 09:07
  • @IngoKegel Thank you. Does the response imply that rather than a module-path argument, that the JavaFX jars if placed on the module path in the Installer Java Invocation list should work? Or the mods rather than jars? We have tried several alternatives, and still no luck. If we call the JVM by hand at the command prompt with the -module-path as above the application starts. However, if we use the install4j launcher we get an error (unable to find javafx). A clear example of how to include JavaFX for a non modularized application with install4j would be appreciated. – BRM Dec 10 '19 at 00:10
  • Actually, for Java 11+ you should add JavaFX to the JDK bundle via jlink, this is what the JRE bundle creation in install4j does if you add the JMODs there or select them for the Liberica JDK provider which offers JavaFX by default. However, you should be able to add it on the module path configuration, too. Probably, the VM parameter `--add-modules ALL-MODULE-PATH` does not work in this case and you have to specify the actual JavaFX modules, like `--add-modules=javafx.controls`. – Ingo Kegel Dec 10 '19 at 06:41
  • An example using install4j of a non modular application which depends on javafx would be very helpful. I see 3 of 4 probable options in the statement above, yet we just need 1 simple example that certainly works. For example, in the statement above, does "add the JMODS there" mean to add them in the install4j Java Invocation list of the Launcher? In the module path list? Also, the statement suggests that --add-modules=javafx.controls can be specified. Where? VM argument in the install4j Launcher Java Invocation? Much thanks, as I bet others are having similar issues. – BRM Dec 10 '19 at 14:14
  • Add the JMODs on the General Settings->JRE Bundles step. Add the VM parameter on the "Java invocation" step of the launcher wizard. For the Liberica provider, the JavaFX modules are part of the JDK modules and can be selected directly on the General Settings->JRE Bundles step. – Ingo Kegel Dec 10 '19 at 14:37

0 Answers0