Compile a single executable with all dependencies


#1

I was asked to evaluate Kotlin as an alternative to learning Java. Running my script currently requires these two long commands:

kotlin hello.kt -include-runtime -cp xchange-core-4.2.0.jar;xchange-bitstamp-4.2.0.jar -d hello.jar
java -cp xchange-core-4.2.0.jar;xchange-bitstamp-4.2.0.jar;slf4j-api-1.7.21.jar;slf4j-simple-1.7.21.jar;rescu-1.9.0.jar;commons-io-2.5.jar;jackson-databind-2.8.4.jar;jackson-core-2.8.4.jar;jackson-annotations-2.8.0.jar;jsr311-api-1.1.1.jar;signpost-core-1.2.1.2.jar;hello.jar HelloKt

Is it possible to make Kotlin produce single file that I can put and run on remote server?


#2

You can use gradle or maven to build a fat jar.


#3

have a look at the Gradle application plugin, that probably does what you are looking for.


#4

@fvasco can you recommend a good tutorial/link that gets straight to the point of making a fat jar with Maven? Like the one that sysadmin can understand and apply quickly to rebuild the project.


#5

You may look for Apache Maven Shade Plugin.


#6

You can build JAR file using Maven. Take a look at the post