JavaFX Application (JDK and JRE 8) Issue Greenfoot Ubuntu 18.04

I recently installed JRE 8 and JDK 8 to use Greenfoot in Ubuntu 18.04.

I know the majority of my Java install works (I can write code in atom and run it with scripts). However, when I try to launch greenfoot in the terminal, I get the following:

Exception in thread "main" java.lang.NoClassDefFoundError: javafx/application/Application
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at bluej.Boot.main(Boot.java:193)
Caused by: java.lang.ClassNotFoundException: javafx.application.Application
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 13 more

It appears to be an issue with greenfoot not being able to find and run the JavaFX classes. From my understanding, JavaFX install comes with JRE 8.

Does JavaFX come with the default JRE 8 and JDK 8 installs?
Do I need to point greenfoot to the JavaFX locations?

Even if you are not familiar with greenfoot, any help would be appreciated. I saw other posts that seemed to be dealing with a similar issue but was not sure how to apply the fix at all in my situation.

Please help!

Answer

Okay. I feel like an idiot. But here are the things to try if you also have this problem:

  • Make sure you downloaded the oracle version of JDK8 (you only need the JDK), the version you download via apt does not have FX (I believe).

  • Make sure your greenfoot installation is using the oracle JDK8

  • Try using the pure java version. This allows you to specify where your JDK install is, making it easy to choose the oracle JDK.

Attribution
Source : Link , Question Author : Tomahok , Answer Author : Tomahok

Leave a Comment