tornadofx icon indicating copy to clipboard operation
tornadofx copied to clipboard

Missing JavaFX runtime

Open carrot-cookie opened this issue 4 years ago • 5 comments

Here is my build.gradle file (Gradle 6.1.1):

plugins {
    id "org.jetbrains.kotlin.jvm" version "1.3.72"
    id "application"
    id 'org.openjfx.javafxplugin' version '0.0.9'
}

version "0.1"
group "com.liberty.client"

repositories {
    mavenCentral()
    jcenter()
}

javafx {
    version = "12"
    modules = ['javafx.controls', 'javafx.graphics']
}


dependencies {
    implementation("no.tornado:tornadofx:1.7.20")
    implementation("org.jetbrains.kotlin:kotlin-stdlib")
}

compileKotlin {
    kotlinOptions.jvmTarget = "11"
}

compileTestKotlin {
    kotlinOptions.jvmTarget = "11"
}

Client.kt:

class Client: App(MyView::class) {
    fun main(args: Array<String>) {
        launch<Client>(args)
    }
}

MyView.kt:

class MyView: View("Login") {
    override val root = vbox {
        button("Press me")
        label("Waiting")
    }
}

When i try to start application, i get error:

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

Took adjustment data from guide.

What could be the problem?

carrot-cookie avatar Jul 09 '20 17:07 carrot-cookie

Try moving the main function outside of the App class.

JavaFX can either run the class Client, or launch it from the main Kotlin function (treated like a class by the name of MainKt). I suspect when you launch from inside the app class, it can only access resources within that class, excluding the javafx runtime.

xcporter avatar Jul 11 '20 23:07 xcporter

Hello! I did as you said. But compiler says me: Error: Main method not found in class com.app.Application, please define the main method as:

I notice gradle run works best, and my small app is starting. But there is another problem: it works without main function. if I add a main function I get an error:

Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.NullPointerException
Caused by: java.lang.NullPointerException

carrot-cookie avatar Jul 12 '20 04:07 carrot-cookie

add Kt to the class name, main.kt -> MainKt

SchweinchenFuntik avatar Jul 12 '20 08:07 SchweinchenFuntik

Hey,this project only supprot jdk8,not supprot jdk11,Please see the readme

please use jdk8 to run the application

the author has worked to tornadofx2 to support jdk9+

stars-one avatar Jan 19 '21 09:01 stars-one

#1332 Check this out, I think your problem the same

ACLzz avatar Jun 18 '21 00:06 ACLzz