Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8248122

java.base should not handle JavaFX application in a specific way

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Can be reproduced with any Java version 11+ and JavaFX 11+ on any OS

      A DESCRIPTION OF THE PROBLEM :
      When using Java 11+ with JavaFX dependencies on the classpath an JavaFX application can not be started. With Java 11+ JavaFX is only useable when it is on the module-path. This is not an issue regarding JavaFX but Java / OpenJDK. JavaFX would work from the classpath. The cause of the problems is in the sun.launcher.LauncherHelper class that is part of the java.base module. This class checks ff the main class of a started application extends the „javafx.application.Application„ class. If this is the case the application will only start if the „javafx.graphics„ is in the module-path (see sun.launcher.LauncherHelper.FXHelper.setFXLaunchParameters). If the module can not be found the application ends with System.exit(1) and an error message.

      Some information about the „javafx.application.Application„ class: This class defines the default lifecycle of a JavaFX application. Therefore a lot of applications directly extend this class for the main class of the application.

      From my point of view such behaviour must not be part of the java.base module. Once JavaFX was removed from the JDK all references should have gone. If JavaFX would only be useable if it is on the moduelpath this must be check by JavaFX and not by OpenJDK. To be true it is not possible to have JavaFX on the module-path. You can easily create a basic main class that does not extend „javafx.application.Application„ and call the main of a class that extend „javafx.application.Application„ internally. By doing so an application would work. But this is really an ugly workarounds (see https://github.com/karakun/OpenWebStart/blob/master/documentation/faq/FAQ.adoc#how-to-run-openjfx-based-javafx-applications-with-openwebstart for a sample).


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create an Java application and add JavaFX (javafx.graphics-win for example) to the class path

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Application starts normally
      ACTUAL -
      application ends (System.exit(1))

      ---------- BEGIN SOURCE ----------
      see https://github.com/karakun/OpenWebStart/blob/master/documentation/faq/FAQ.adoc#how-to-run-openjfx-based-javafx-applications-with-openwebstart
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      see https://github.com/karakun/OpenWebStart/blob/master/documentation/faq/FAQ.adoc#how-to-run-openjfx-based-javafx-applications-with-openwebstart

      FREQUENCY : always


            kcr Kevin Rushforth
            webbuggrp Webbug Group
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: