Attempting a Hello World Example, Failure

Hi guys,

I’m new here, and I’m getting flumoxed by a simple hello world example.  I’m using the stand alone compiler, and trying to compile a simple Kotlin program.  I believe the following shell output describes everything.  Notice the class not found error.  I unpacked kotlin-runtime.jar, and there certainly seems to be a class that fits the description of the path that’s not being found, so I’m very confused.  I usually don’t run things from the command line, so perhaps I’m just using Java incorrectly?

Any thoughts would be appreciated.

``

acolombi@acolombi-mbp /tmp/testo
$ cat hw.kt // here is the code I’m trying to run
fun main(args : Array<String>) {
  println(“Hello, world!”)
}

acolombi@acolombi-mbp /tmp/testo
$ sh /tmp/kotlinc/bin/kotlinc-jvm hw.kt -jar hw.jar // it seems to compile just fine

acolombi@acolombi-mbp /tmp/testo
$ java -cp /tmp/kotlinc/lib/kotlin-runtime.jar -jar hw.jar // run my brand new JAR, and use the Kotlin runtime
Exception in thread “main” java.lang.NoClassDefFoundError: kotlin/io/namespace
     at namespace.main(hw.kt:2)
Caused by: java.lang.ClassNotFoundException: kotlin.io.namespace
     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
     … 1 more

acolombi@acolombi-mbp /tmp/testo
$ java -version // java version, in case you care
java version “1.6.0_35”
Java™ SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
Java HotSpot™ 64-Bit Server VM (build 20.10-b01-428, mixed mode)

acolombi@acolombi-mbp /tmp/testo
$ sh /tmp/kotlinc/bin/kotlinc-jvm -version // kotlin version, in case you care
INFO: Kotlin Compiler version 0.4.254
Kotlin interactive shell
Type :help for help, :quit for quit
>>>

Andrew, The '-jar' option is not fully supported yet. The exact problem in your example is that 'java -jar' ignores its classpath argument, hence one of the Kotlin classes is not found. (http://youtrack.jetbrains.com/issue/KT-3116) Please use compilation to classfiles (and 'jar' utility later if you need) instead:

kotlinc-jvm a.kt -output .