Getting JavaFX to work in Eclipse IDE these days is a bit tricky since JavaFX aren't included in the JDK and Eclipse is not set up from start to work with FX Applications.
JavaFX is now a seperate project.
Step 1: Install the latest Java JDK.
Step 2: Install the latest version of Eclipse (I used version 2019-06).
Step 3. Install JavaFX
Step 4: Add e(fx)clipse Runtime and IDE to Eclipse IDE
Step 5. Start a new JavaFX project.
STEP 1 - Install the latest JDK (Java Development Kit)
1. Download the JDK from Oracle's website at: https://www.oracle.com/technetwork/java/javase/downloads/index.html download a suiting Java Platform standard edition JDK for your operating system.2. Install the JDK to your system
3. Set the environment variable for Java JDK
STEP 2 - Install the latest Eclipse IDE
Download the latest Eclipse IDE from https://www.eclipse.org/Install Eclipse to your system.
STEP 3 - Install the latest JavaFX
Download the latest JavaFX from https://openjfx.io/Extract JavaFX files. I extracted them to my Java library to keep all Java related files in the same folder.
STEP 4 - Install e(fx)clipse Runtime and IDE to Eclipse IDE
This is all done in Eclipse.
1. Install the e(fx) runtime for Eclipse.
Open Help/install new software
At work with add following site: http://download.eclipse.org/efxclipse/runtime-nightly/site
Select and install FX Runtime and FX Target
2. Install the e(fx) IDE for Eclipse.
Open Help/install new software
At work with add following site: http://download.eclipse.org/efxclipse/updates-nightly/site
Select the software for e(fx)clipse and install
Restart Eclipse
3. Check for new updates.
Open Help/check for updates
In Eclipse go to Eclipse/preferences/Java/Build Path/User Libraries/
Press new and enter a name for example JavaFX12, then OK.
Then Add external JARs to this library, navigate to the lib folder for your JavaFX installation and choose all the included JARs.
Links
https://projects.eclipse.org/projects/technology.efxclipse
https://www.eclipse.org/efxclipse/index.html
https://wiki.eclipse.org/Efxclipse/Tutorials/AddingE(fx)clipse_to_eclipse
Runtime Updatesite:
http://download.eclipse.org/efxclipse/runtime-nightly/site
IDE Updatesite:
http://download.eclipse.org/efxclipse/updates-nightly/site
Step 5 Create a new JavaFX project
I created a JavaFX project to test if it was working. It didn't. I had the following error.
Error: Could not find or load main class application.Main
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application
Add JavaFX library to project
I needed to change my Build Path for the project. I added my user library for JavaFX which was not included automatically.Add VM argument to project
I also had to add a VM argument to my JavaFX project in Eclipse. This was described on JavaFX website.https://openjfx.io/openjfx-docs/
In the project you choose "Run As" / Arguments
In VM Arguments you add this (but make sure to set this path correct for your JavaFX files);
--module-path "C:\Program Files\Java\javafx-sdk-12.0.1\lib" --add-modules javafx.controls,javafx.fxml
If someone knows how to fix so that this works without having to set each project with module path please let me know.
0 comments:
Post a Comment