Reputation: 1945
It's well known that for a fatjar to run properly for more recent versions of javafx applications the main class that launches the application cannot inherit from the Application class. The easy work around is creating a launcher class that calls the main method of the main class.
I'm having trouble doing this with Kotlin and TornadoFX (pretty new to both).
My example app is minimal:
class MyApp: App(MainView::class, Styles::class)
The question is how can I start this class from another launcher class?
Upvotes: 2
Views: 474
Reputation:
I think the simplest and possibly best way to do this is with a function as follows.
If we make a Kotlin file Launcher.kt name is not important. Contents below
package my.app
class MyApp: App(MainView::class, Styles::class)
// stand alone function
fun main(args: Array<String>) {
launch<MyApp>(args)
}
then the main class name would be
mainClassName = 'my.app.MyAppKt'
now we have a main class declaration this is used in the jars manifest or we could use the shaddow plugin for creating fat jars as shown here Shadow JAR
Note the launch function here is from tornadofx.App.kt
Upvotes: 4
Reputation: 841
What I've done is put the function:
fun main(args: Array<String>) {
launch<MyApp>(args)
}
In the same file, but outside of the App class. I then have my IDE and build tool (Maven in my case) point to this file.
Upvotes: 3