TornadoFX: Migrating JDK 8 to OpenJDK 11

May 27 · 4 min read

As much as I really love JDK 8, it’s past time to upgrade my TestFX-Suite to use JDK 11. Actually, Oracle released their latest version JDK 12 on March 19 of this year and will expect to push more frequent updates, but as TornadoFX is kept up with tender-loving care from the community in their spare time, the migration for TornadoFX to JDK 11 was a huge undertaking for us and that’s where we happen to be at.

Perhaps that will be a conversation that will need to be had in the future on our end.

In the meantime, let’s take my TornadoFX-Suite project and have that migrated to JDK 11.

Getting set up with OpenJDK 11

Let’s start with getting JDK 11 working. Y̶o̶u̶ ̶c̶a̶n̶ ̶g̶r̶a̶b̶ ̶J̶D̶K̶ ̶1̶1̶ ̶f̶r̶o̶m̶ ̶t̶h̶e̶ ̶O̶r̶a̶c̶l̶e̶ ̶w̶e̶b̶ ̶s̶i̶t̶e̶.̶ Well… I just found out what Oracle had done to Java. I tried to download JDK 11 and apparently, we can no longer get it for free.

As friends have suggested:

There’s lots of places where you can download OpenJDK — I just went with

Getting set up with OpenJDK 11

JavaFX has been removed from the Java JDK as of JDK 11 — this is not necessarily a bad thing! JavaFX has been moved to open-source software and is being maintained and improved on more than ever.

If we’re going to be working with JDK 11 in TornadoFX, we’ll need to download OpenJFX. In your bash file, you’ll want to add the following:

export PATH_TO_FX=${path}/javafx-sdk-11.0.2/lib

Have you switched your version to JDK 11? If not, go ahead.

You can get the home of your openJDK from the ending installation screen seen above. I still use JDK 8 for my Android work, so I want to be able to switch between the two versions quickly and easily. This can be achieved by setting the following in your ~/.bashrc file:

export JAVA_HOME=$(/usr/libexec/java_home -v 11)export PATH=$JAVA_HOME/jre/bin:$PATHalias jdk11="export JAVA_HOME=`/usr/libexec/java_home -v 11`; java -version"alias jdk8="export JAVA_HOME=`/usr/libexec/java_home -v 1.8`; java -version"

As long as your remember to source your file, you can change between the two!

Migrating your project to OpenJFX

As with any project that poses high risk for breaking your code, it’s always best practice to start this on a new branch.

On the wild chance IntelliJ is unable to locate the JDK you have just installed, you may need to add it manually. You can add it by clicking “New” and selecting the file:

This can be done either in editing Run Configurations or the Project Structure.

Once you’ve done that, head to your Project Structure in IntelliJ and switch your version to JDK 11.

Project Structure > Project to set Project SDK to 11

The result? Everything breaks — as mentioned before, JavaFX had been removed from JDK 11, so it’s only natural that our project has no idea what JavaFX is.

Everything is on fire!!! Nah. You just have to add open JavaFX.

Gluon did a very cool thing and offered to maintain OpenJFX. Go ahead and download the platform specific runtime for your system here.

Once OpenJFX is downloaded and unpacked, you’ll need to add the project in Project Structure in the Global Library. You won’t need anything else but the classes.

Project Structure > Libraries to import SDK11 locally.

Right-click the global JavaFX package to add to your project modules. Once that’s done, you’ll want to make sure

Make sure your SDK is set at 11 via Project Structure > Modules

Now, you may end up with some error along the lines of

JavaFX runtime components are missing, and are required to run this application

To fix this, you need to add the following VM options in your TornadoFX Run/Debug Configurations:

--module-path /Users/${wherever you unpacked the package}/javafx-sdk-11.0.2/lib --add-modules=javafx.controls,javafx.fxml

You should be able to run your project now. So good to see TornadoFX-Suite again!

Helpful Idea!

You can use IntelliJ’s Problems section to automatically fix anything out of whack it detects.

Large thanks to the KotlinLang #tornadofx community for assisting me through the process and proofreading the article, especially Abhinay Agrawal, Carl Walker, Alexander Birukov, and Alexander Falb.

If you’re already not on, come and join!


Written by


software engineer and crocheting enthusiast

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade