Reputation: 93
While I was playing around with Kotlin I wondered if I can generat a jar for a JavaFX app written in Kotlin. So I wrote a simple app and it worked on IntelliJ IDEA, but when I decided to generate the jar it never worked! It says that it can't find or load the main class.
I guess the problem is that when it asked for the main class in the project settings I entered the application class name (which doesn't contain the main method, as it has to be at the package level) while in pure Java I could just put the main method inside the application class and it would work perfectly. So how should I get around this?
EDIT: just tried changing the target from JavaFX Application to a normal Jar and it worked. Don't know why it's not working with the JavaFX Application target.
Upvotes: 3
Views: 1418
Reputation: 25767
If you have your main function defined in package named foo.bar
:
package foo.bar
fun main(args: Array<String>) {
// ...
}
Then, your main class is foo.bar.BarPackage
- it is generated by Kotlin compiler to hold top-level functions of the package
Upvotes: 1