Instructions for complete Hello World?



I am not able to find instructions on how to compile a Hello World program and run it using a “Standalone compiler” from a command line. Is that hidden somewhere?

By trial and errors, I did something like this. Is there an easier way?


bash> cd $HOME
bash> unzip
bash> chmod a+x kotlinc/bin/*

bash> cat << ‘EOM’ > Hello.kt
fun main(args : Array<String>) {

bash> kotlinc/bin/kotlinc-jvm -src Hello.kt -jar hello.jar
bash> java -cp “kotlinc/lib/*:hello.jar” namespace

It would be nice this be part of Getting Started Guide such as here



To be honest, the easiest ways to play with Kotlin are to either use Kotlin Web Demo or IntelliJ IDEA plugin. If neither of these options are convenient to you, surely you can use command-line compiler. Unfortunately, it is not documented yet, but you can always run kotlin-jvm with "-help" option to see list of available options. Anyway, we'd better add some simple how-to for it.

The way you found is correct. There is an alternative way of storing compiled program: instead of creating jar, you can have compiled classes in some directory, using “-output <dir>” instead of “-jar <jar-file>”.


that was 2012; now it’s late 2017. is there a simlple gradle/kotlin hello world example?


Looks like the repo on Github have one.