Jar file only works with Java classes but not with Kotlin

You could try this one here https://github.com/dittert/minimalkotlin to compare what is different in your setup.

git clone https://github.com/dittert/minimalkotlin.git will clone it locally. Then, you can open it up in IntelliJ.

I just looked at your screenshots: That can’t work. You do not include any of your classes. Here is how it is supposed to look like. To add your classes, you can click on the plus button and select Module output.

And your NoClassDefFoundError errors are probably because you include the Kotlin runtime into the JAR instead of the contents of their JARs. Java does not support reading library JARs from inside a JAR file.

To solve that:

  1. Remove KotlinJavaRuntime (Project Library) on the left hand side (i.e. future contents of the JAR file)
  2. Select KotlinJavaRuntime (Project Library) on the right hand side
  3. Select Extract Into Output Root from the context menu

IDEA will then extract the contents of the library JARs and put those files into the JAR file that is generated on build. You should then be able to run it with java -jar <path to jar file>.

Hope that helps!