Hi, I'm new to JavaFX and TornadoFX (which I'm try...
# tornadofx
a
Hi, I'm new to JavaFX and TornadoFX (which I'm trying to use for a small desktop app) so I'm probably missing some basic concept, but I've been looking around for a couple days now and nothing I've tried so far works. Whenever I try running the app it fails with error
Copy code
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application
From what I understand that seems to be linked to JavaFX missing, but I'm using JDK8 with TornadoFX 1.7.19 I've also tried running a View on its own and it fails with error
Copy code
Caused by: java.lang.NoSuchMethodError: javafx.stage.Window.getProperties()Ljavafx/collections/ObservableMap;
which looks to me like the same error except more verbose. I am using the Oracle JDK and haven't tried OpenJDK yet.
b
you have JDK without JavaFx
a
I thought that too, but I can see the JDK I have includes jfxrt.jar which I read on stackoverflow should mean JavaFX is present. is that wrong?
b
you need to make sure that the project uses exactly the JDK you need. IDEA Ctrl + Alt + Shift + P
a
yes I'm fairly sure I have the correct JDK selected for the project, I did try changing it to another version earlier today and it stopped recognizing imports in my classes
oh, i forgot to mention that my App class imports
Copy code
import javafx.scene.text.FontWeight
without any errors, which is why I believe the JDK to be correct, and JavaFX to be present
b
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application
- is it a runtime error?
a
yes
b
you are running on the wrong jdk. for ubuntu helps
sudo apt install openjfx
a
I'm sorry, I don't understand, if I'm using JDK8 shouldn't JavaFX work? I've tried changing JDK multiple times already but it doesn't fix the issue. I don't need newer versions right now so I figured there was no need for openjfx. Can I not use TornadoFX without it?
b
TornadoFX is an add-on for JavaFx
here you need to understand the build system and how you run the project
a
yes, but JavaFX is still included in the JDK I'm using, according to the github repo it should work when targeting jvm1.8, and only mentions JavaFX being decoupled from JDK9+
b
This is not a Tornadofx problem. There is a difference in the assembly of the project and its launch. In this case, you run the wrong JDK
How did you create the project?
a
I created the project on IntelliJ as a Kotlin/JVM project then added tornadofx dependency through gradle (kotlin dsl)
b
enter to terminal
java - version
a
Copy code
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
b
and run how? through gradle?
a
I tried both with the default "run" gradle task and with an Application configuration directly from IntelliJ
b
Application: run
a
this is what mine looks like
b
Is the
Application
plugin configured ? Is the application plugin configured?
a
this is what I have after following the setup guide
b
not the best run option. Have you tried this? https://docs.gradle.org/current/userguide/application_plugin.html
a
yes I have that too
Copy code
plugins {
    kotlin("jvm") version "1.3.50"
    application
}

application {
    mainClassName = "main.kotlin.app.AppCore"
}

repositories {
    mavenCentral()
}

dependencies {
    implementation(kotlin("stdlib-jdk8"))
    implementation("no.tornado:tornadofx:1.7.19")
}
b
also check the environment variable JAVA_HOME
a
I have it pointing to my JDK8
Copy code
C:\Users\Omashano>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_25
b
sorry then i dont know gradle option should work. Also try uninstalling all the JDKs and reinstalling them, just see if JavaFX is there
a
Ok, I will try that tomorrow. Thank you for your time.
Uninstalling everything and installing back everything fixed the issue, thank you again for the help.