Launching JavaFX apps
kevin.rushforth at oracle.com
Wed Jan 8 06:45:36 PST 2014
The Java 8 launcher has been modified to recognize JavaFX applications
-- that is, classes that extend javafx.application.Application -- and
launch them directly by calling into the JavaFX launcher code. See
JDK-8001533 <https://bugs.openjdk.java.net/browse/JDK-8001533>. This is
why the com.javafx.main.Main class is no longer needed.
Somewhat independent of this, for standalone applications (but not
applets or web start applications) the JavaFX launcher code will now
call the main() method if it is present (see RT-28755
<https://javafx-jira.kenai.com/browse/RT-28755>), but will still happily
launch the application if it isn't. So the main() method is still
optional. If present, it must call Application.launch() in order to
launch the application.
So yes, it does seem that Netbeans should modify the wording of their
javadoc comment for the main() method of a JavaFX application.
Scott Palmer wrote:
> Based on the discussion I saw in the comments for RT-34236 I discovered
> that using com.javafx.main.Main is not the way JavaFX 8 is supposed to
> work. There are comments that read, "...making sure their Application class
> has a main that calls launcher(String args)."
> This seems to imply that a main method is now required in the Application
> class when writing apps for JavaFX 8.
> Is this correct?
> If so. Somebody should tell NetBeans to stop injecting this comment in the
> generated application class for JavaFX projects:
> * The main() method is ignored in correctly deployed JavaFX application.
> * main() serves only as fallback in case the application can not be
> * launched through deployment artifacts, e.g., in IDEs with limited FX
> * support. NetBeans ignores main().
> * @param args the command line arguments
> Are the changes to the launching of JavaFX apps docuemtned somewhere? Is
> using javafxpackager or the ant task the *only* supported way of creating
> JavaFX applications? I'm currently using my own stub that runs on Java 7
> and adds the jfxrt.jar to the classpath if required and then calls the
> launch method on the Applicaiton class.
More information about the openjfx-dev