Hello,
since I found Kotlin pretty useful for programming Android-apps, I tried programming some pretty simple command line programm I found in the reference on the Kotlin site. Running the whole thing inside IntelliJ has never been a problem, but creating a .jar file by building an artifact is quite tricky.
- I have not been able to choose a kotlin file / class as main class, I solved it by using a Java class as main class
- The second problem is, that as soon as I am trying to access a method from the Kotlin class through the Java class I get the following error(s):
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics at de.DJJD.programme.myFunctions.cases(myFunctions.kt) at de.DJJD.programme.main.main(main.java:9) Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 2 more
So im trying to access the myFunctions.kt class using the following code
public class main { public static void main(String[] args) { myFunctions f = new myFunctions(); f.cases(1); } }
Once I put some simple code into a java class that just prints out the the parameter coming from the main class, it works!
What could be the problem?
I already added the KotlinJavaRuntime lib in Project Structure | Artifacts
and tried it using Gradle as shown on the reference page, but it does never find the classes as soon as I use Kotlin…
Thanks for your help,
Julian
If someone could provide me some working (/compilable) Kotlin project as a sample which I can import and see what settings I have to use, that would be great!