Can I export a JAR file with only Kotlin classes, without any Java class?

Asked

Viewed 156 times

2

I’m using Intellij IDEA to develop a project in Kotlin, and I’ve reached a point where I need to create an executable file to run on the server, but when I try to create a JAR Artifact, I cannot because I need to report a Main Class in Java, something that is not in the project. Do you have any solution?

1 answer

1


You can define a class with the method main recognized by Intellij in two ways:

object MainClass {
    @JvmStatic
    fun main(args: Array<String>) {
        println("Sou uma classe com um main definido")
    }
}

Or:

class MainClass 

fun main(args: Array<String>) {
    println("Sou uma classe com um main definido")
}

Both cases are listed as possible main classes for your jar:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.