Compiler cannot find JDK rt.jar


#1

Just starting with Kotlin. Downloaded the M5 command line compiler but it complains about not finding "the JDK rt.jar" in my jre directory, even though it is in the standard ...jre6lib location. Though it is not well documented, I found a compiler switch, -noJdk, that that lets the compiler run but I suspect that is not the correct solution. I'm sure it's a simple problem, but the documentation for command line users is really poor. Any ideas? No desire to install and learn an IDE just to try out the language, so please don't suggest that.

I am able to compile and run simple Kotlin programs, but it was far harder than it needed to be. Too bad given the fine job you are doing on the language design.

I have some other questions but will post them separately.


#2

You need a JDK, not a JRE installed.


#3

Andrey, thanks for getting back to me.

I have the JDK (version 6 update 39) installed, that is not the problem.

After looking into this, I think I have it figured out. I was using a JRE installed in an alternate directory. The logic in PathUtil.findRtJar() works fine if the JRE is part of the JDK, but seems wrong for a stand alone JRE. It looks for jredir/jre/lib/rt.jar. It should look for jredir/lib/rt.jar. Once I knew how it worked, it was easy to deal with.

A minor point. The compiler error message seems misleading. It labels rt.jar as a JDK file, but it is really a JRE file.

Also, you said the JDK was required. I realize that early Kotlin users will most likely have the JDK, since many programs will be a Kotlin/Java mix, but is it actually needed for pure Kotlin development?

Anyway, things are working fine and I look forward to to writing some Kotlin code.


#4

We are working on this issue already and going to allow compile with JRE only pretty soon. You can subscribe to KT-2599 if you want to be notified when it is done.