gradlejavafxkotlintornadofx

Gradle Compilation can't find tornadofx on Linux


I am trying to compile a kotlin application with gradle. The application uses tornadofx (kotlin version of javafx).

In build.gradle, I have:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    compile 'no.tornado:tornadofx:1.7.8'
    compile 'com.squareup.moshi:moshi:1.5.0'
    compile 'com.squareup.moshi:moshi-kotlin:1.5.0'

    // Required for local unit tests (JUnit 4 framework)
    testCompile 'junit:junit:4.12'
}

In MyApp.kt I have:

import javafx.application.Application
import tornadofx.App

When I compile this project on Windows 10, either with gradle clean build or .\gradlew clean build, it compiles and works perfectly.

When I compile this project on Ubuntu Linux, I get a page of error messages, including:

...

e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
    class tornadofx.UIComponent, unresolved supertypes: javafx.event.EventTarget
    class tornadofx.App, unresolved supertypes: javafx.application.Application

...

e: /home/al/project/app/src/pcUi/MyApp.kt: (3, 8): Unresolved reference: javafx
e: /home/al/project/app/src/pcUi/MyApp.kt: (12, 5): Unresolved reference: Application

...

Although if I do this from a clean set-up, the gradle output also includes:

Download https://jcenter.bintray.com/no/tornado/tornadofx/1.7.8/tornadofx-1.7.8.pom
Download https://jcenter.bintray.com/com/squareup/moshi/moshi/1.5.0/moshi-1.5.0.pom
Download https://jcenter.bintray.com/com/squareup/moshi/moshi-parent/1.5.0/moshi-parent-1.5.0.pom
Download https://jcenter.bintray.com/com/squareup/moshi/moshi-kotlin/1.5.0/moshi-kotlin-1.5.0.pom
Download https://jcenter.bintray.com/org/glassfish/javax.json/1.0.4/javax.json-1.0.4.pom
Download https://jcenter.bintray.com/org/glassfish/json/1.0.4/json-1.0.4.pom
Download https://jcenter.bintray.com/net/java/jvnet-parent/3/jvnet-parent-3.pom
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.1.3/kotlin-stdlib-jre8-1.1.3.pom
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.1.3/kotlin-reflect-1.1.3.pom
Download https://jcenter.bintray.com/com/squareup/okio/okio/1.13.0/okio-1.13.0.pom
Download https://jcenter.bintray.com/com/squareup/okio/okio-parent/1.13.0/okio-parent-1.13.0.pom
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre7/1.1.3/kotlin-stdlib-jre7-1.1.3.pom
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.3/kotlin-stdlib-1.1.3.pom
Download https://jcenter.bintray.com/no/tornado/tornadofx/1.7.8/tornadofx-1.7.8.jar
Download https://jcenter.bintray.com/com/squareup/moshi/moshi/1.5.0/moshi-1.5.0.jar
Download https://jcenter.bintray.com/com/squareup/moshi/moshi-kotlin/1.5.0/moshi-kotlin-1.5.0.jar
Download https://jcenter.bintray.com/org/glassfish/javax.json/1.0.4/javax.json-1.0.4.jar
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre8/1.1.3/kotlin-stdlib-jre8-1.1.3.jar
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.1.3/kotlin-reflect-1.1.3.jar
Download https://jcenter.bintray.com/com/squareup/okio/okio/1.13.0/okio-1.13.0.jar
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jre7/1.1.3/kotlin-stdlib-jre7-1.1.3.jar
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.3/kotlin-stdlib-1.1.3.jar

This doesn't make sense to me as it's downloading the dependencies correctly (on Linux and Windows), but then only succeeding to compile on Windows and not Linux. I haven't been able to figure out what's going on, so can anyone offer any suggestions for where to look?


Solution

  • See the error message:

    e: /home/al/project/app/src/pcUi/MyApp.kt: (3, 8): Unresolved reference: javafx e: /home/al/project/app/src/pcUi/MyApp.kt: (12, 5): Unresolved reference: Application

    It seems like you do not have your JDK set up correctly on Ubuntu. JavaFX is no longer a part of the OpenJDK, you have to install it manually: https://packages.qa.debian.org/o/openjfx.html .

    Edit: see https://stackoverflow.com/a/43301246/4697327 . You're probably using the Oracle JDK on Windows, which has JavaFX included.