Tuesday, April 7, 2020

The Joys of setting up JavaFX in Eclipse IDE (but it actually worked at the end of it all)

The installation of a version of Eclipse required JDK version 1.8 (aka JDK 8), and Eclipse Neon.
I spent way too much time getting JavaFX to work on Eclipse on my Mac.
Here is the original error in Eclipse when trying to import JavaFX:



The official error I was getting when trying to use the program was something like: java.lang.NoClassDefFoundError: javafx/application/Application
Notice the red underline underneath javafx.application.Application; and the "extends Application"

I was not able to use JavaFX in my version of Eclipse. It took me a while to realize that on the website for the JavaFX installation in Eclipse (e(fx)clipse: https://www.eclipse.org/efxclipse/install.html#for-the-lazy) they did not provide the web address.

There is a separate website to install a the Eclipse IDE with all the packages pre-installed (https://efxclipse.bestsolution.at). I chose the "Get Started Fast" option.

Try to install a version of Eclipse with JavaFX already installed. After installing the 380 MB file, I moved the file to my applications folder, to be met with this:

"Eclipse" is damaged and can't be opened. You should move it to the Trash.

The program is quarantined and you must use these commands in the terminal to un-quarantine it:

1. Open the terminal and make the working directory the file with Eclipse (use cd \path to eclipse .... which is \Applications in my case since I moved Eclipse there)
2. type in: $ xattr Eclipse.app/
You should see com.apple.quarantine
3. Remove the quarantine with xattr -d com.apple.quarantine Eclipse.app/

Opening the Eclipse launcher I found this error:


An error has occurred. See the log file.  ...Eclipse/metadata/log

To fix, right click on the Eclipse icon, go to show package contents, then go to Contents --> Eclipse --> Eclipse.ini. To change the eclipse.ini file, add in where my virtual machine (JVM) is located. This site explained it well. A command needed to be added before vmargs:

-vm
/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home/bin

If you did not point the ini file to JVM 1.8 you will see this error message:


It finally worked:

Yea!

1 comment:

  1. I am very much obliged to you for sharing this necessary knowledge. This information is very helpful for everyone. So please always share this kind of information. Thanks once again for sharing it. pls visit our website testing and tagging sydney

    ReplyDelete