How to create an exe from TornadoFx and Kotlin

Hello everyone!

I have an application written in Kotlin and I used TornadoFx to build a GUI around it. As stated in the TornadoFx guide, I used OpenJDK11 and set kotlin.jvmtarget to “11”. Here is my gradle build:

plugins { id 'org.jetbrains.kotlin.jvm' version '1.4.30' id 'application' id 'org.openjfx.javafxplugin' version '0.0.9' id 'java' id 'edu.sc.seis.launch4j' version '2.4.9' } group = 'me.nicola' version = '1.0-SNAPSHOT' repositories { mavenCentral() } application { mainClassName = "Engine" } javafx { version = "11.0.2" modules = ['javafx.controls', 'javafx.graphics'] } dependencies { testImplementation 'org.jetbrains.kotlin:kotlin-test-junit' implementation 'no.tornado:tornadofx:1.7.20' implementation group: 'org.apache.commons', name: 'commons-email', version: '1.5' implementation 'com.github.doyaaaaaken:kotlin-csv-jvm:0.15.0' } test { useJUnit() } jar { manifest { attributes "Main-Class" : "EngineKt" } } compileKotlin { kotlinOptions.jvmTarget = "11" } compileTestKotlin { kotlinOptions.jvmTarget = "11" } task fatJar(type: Jar) { baseName 'PrimaNotaHelper' manifest { attributes "Main-Class": "EngineKt" } from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } with jar } launch4j { mainClassName = 'EngineKt' //icon = "${projectDir}/icons/myApp.ico" } 

I’m trying to use Launch4J to bundle my app into an executable for windows (.exe) and it compiles correctly when I launch the “launch4j” task, building the “lib” folder and the .exe file. However, once I’m on Windows the executable does not work.

I also tried to use the Launch4J GUI for Windows and played around a little bit with that but nothing works for me: either It simply crash before starting or ask me for a different version of the JRE.

Can someone help me to set up my build correctly?

Thank you so much!

submitted by /u/NicolaM1994
[link] [comments]