Adding JavaFX Runtime to Eclipse in Java 11
Java 11 users often encounter runtime errors when attempting to run JavaFX applications due to the framework's exclusion in the latest Java version. This error message informs you that necessary JavaFX runtime components are missing.
To successfully add JavaFX to Eclipse in Java 11, follow these steps:
-
Install Eclipse and JDK 11: Install Eclipse 2018-09 and JDK 11.
-
Add JDK 11 to Eclipse: Navigate to Eclipse > Window > Preferences > Java > Installed JREs, then add Java 11.
-
Download JavaFX 11: Download JavaFX 11 ea from the official website.
-
Create User Library: Go to Eclipse > Window > Preferences > Java > Build Path > User Libraries and click New. Name the library JavaFX11 and add the JAR files located in the JavaFX 11-ea library folder.
-
Create Java Project: Initialize a Java project in Eclipse. Select Java 11 as the Java version and include JavaFX11 in the project's modulepath.
-
Add JavaFX Package and Main Class: Create a package named javafx11 and add the main application class HelloFX.
-
Add Runtime Arguments: Edit the project's run configuration and add the following VM arguments:
--module-path C:UsersDownloadsjavafx-sdk-11lib --add-modules=javafx.controls
-
Run the Project: Execute the project to verify JavaFX integration.
By following these steps, you can effectively add JavaFX runtime to Eclipse in Java 11 and enjoy seamless JavaFX development.
The above is the detailed content of How to Add JavaFX Runtime to Eclipse in Java 11?. For more information, please follow other related articles on the PHP Chinese website!