1

I have a kotlin script file named CheckUtils.kts.

I want to compile the CheckUtils.kts to a jar which can be run with "java -jar CheckUtils.jar". I try to use kotlinc to compile kts file to a jar, but i failed.

 kotlinc src/CheckUtils.kts -include-runtime -d CheckUtils.jar

I got an error when i "java -jar CheckUtils.jar"

.jar has no main manifest attribute

So , how can i compile a kts file to a jar?

littleVega
  • 11
  • 2
  • Does this answer your question? [package a Kotlin .class file in a JAR for execution](https://stackoverflow.com/questions/46978779/package-a-kotlin-class-file-in-a-jar-for-execution) – deepakchethan Jun 30 '21 at 08:29
  • @deepakchethan I try to define a main function in the kts file top level , but no useful. – littleVega Jun 30 '21 at 08:48
  • @deepakchethan Kotlin script file (*.tks), do not need a main funtion to decleared where the code to start execute. – littleVega Jun 30 '21 at 08:50

1 Answers1

0

You can't compile a Kotlin script to an executable fat-jar with kotlinc, but you should be able to make a standalone binary with kscript

jeanpic
  • 481
  • 3
  • 15