[BLUEJ-1212] Linux/OpenJDK: creating Swing/AWT windows throws JavaFX exception in terminal
When BlueJ is run with OpenJDK without OpenJFX installed as part of the JDK itself (i.e. installed separately), as is the case on Debian/Ubuntu, JavaFX isn't available in the user VM unless it is explicitly added as a library. That's fine, but BlueJ intercepts creation of Swing/AWT windows and runs a method which refers to a JavaFX class, resulting in a NoClassDefFound error:
{code} Exception in thread “AWT-EventQueue-1” java.lang.NoClassDefFoundError: javafx/scene/input/KeyCombination at bluej.utility.Utility.appToFront(Utility.java:563) at bluej.utility.Utility.bringToFront(Utility.java:542) at bluej.runtime.ExecServer$2.eventDispatched(ExecServer.java:264) at java.awt.Toolkit$SelectiveAWTEventListener.eventDispatched(Toolkit.java:2427) at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2319) at java.awt.Toolkit.notifyAWTEventListeners(Toolkit.java:2277) at java.awt.Component.dispatchEventImpl(Component.java:4785) at java.awt.Container.dispatchEventImpl(Container.java:2296) {code}
(etc.).
A workaround is to add the OpenJFX runtime jar to the user libraries, via preferences - libraries - add file, then choose /usr/share/java/openfx/jre/lib/ext/jfxrt.jar. This file must be present since BlueJ requires it to run. It may be necessary to re-start BlueJ before the change takes effect.
Issue metadata
- Issue type: Bug
- Priority: Medium
- Fix versions: 4.2.0