Search code examples
kotlinintellij-ideajavafxtornadofx

TornadoFX _ Kotlin _ IntelliJ IDEA: How is it possible that I am getting an "Unresolved reference: javafx" since I am using openJDK 8 in my project?


I am trying to get start with Kotlin and TornadoFX.

I have download Java jdk8u252-b09 and set it as my project SDK. See the following image:

enter image description here

I have seen this post that inform us that the Unresolved reference: javafx's bugg is linked to the fact of running a version of Java greater or equal to v11 without importing JavaFX in the project. I have read the v8 of Java come with JavaFX integrated. And in my project as I have already said, I am running Java 1.8 as SDK. So this problem should be prevented to occur.

Still, when I "debug run" my debug console returns me:

Unresolved reference: javafx

as in the following image:

enter image description here

The only place I see that could be problematic is the software running in my machine. When I am running java --version in a linux terminal it returns me:

openjdk 11.0.7 2020-04-14

Since I am on Debian Buster it seems openjdk 11 is the oldest version supported by the OS-version. So if the problem is linked to the openjdk installed in the system I am wondering if there is any workaround beside running a virtual machine. Also I would think that the SDK installed in IntelliJ IDEA would overcome the Java version installed in my system in the context of my project, hence preventing the software installed in my machine to cause any problem to run my project.

So how my bugg is possible? What can I do to fix that?


Solution

  • In fact in the OpenJDK8 build that I have downloaded the jfxrt.jar was missing.

    So I have download a jfxrt.jar alone and included it in my /jdk8u252-b09/jre/lib/ext/ folder.

    Then the console returned me that a toolkit was missing.

    So, in in /jdk8u252-b09/, I have just completely replaced the original jre of jdk8u252-b09 with the one provided by https://java.com/en/download/linux_manual.jsp.

    In this case ensure effectively that in your Project Structure, in your "Module" part -> "Dependencies" tab, your dependencies point to the relevant folder [thanks DoombringerBG].

    The same for your project's SDK, ensure that it is up to date.

    Concerning your library it should know be okay because of the inclusion of JavaFX in your Java8 folder tree.

    In one word, ensure your project is up to date with your replacement of you jre folder.

    Now my project works fine.