I am trying to find a setup for developing mixed Java and Kotlin applications in Eclipse. Everything seems to work fine for older Versions of Eclipse and that support JDK8. However, for newer Versions and using JDK11, the Kotlin Eclipse plugin does not seem to work as expected.
My setup:
- Fresh installation of Eclipse 2020-06 IDE For Java and DSL developers
- Java VM: Open JDK 11
- Installed Kotlin Plugin for Eclipse 0.8.21
- Installed AspectJ Development Tools 1.9.6 (appears to be required for the Kotlin plugin to work correctly)
Everything works fine when I create a simple Kotlin Project and add a file hello.kt
with the following content:
package hello
fun main() {
println("Hello World!")
}
I then add a java class Foo.java
to the project:
package hello;
public class Foo {
public void foo() {
System.out.println("Foo!");
}
}
This still compiles and runs fine. However, as soon as I modify hello.kt
and use the Java class, the program does not run anymore. This is my modified hello.kt
:
package hello
fun main() {
println("Hello World!")
val foo = Foo()
foo.foo()
}
Compiling still seems to work fine. At least no errors are reported in the IDE. However, when running the application, I get the following error:
Error: Could not find or load main class hello.HelloKt
Caused by: java.lang.ClassNotFoundException: hello.HelloKt
By inspecting the bin directory of the project, I found that in the initial pure Kotlin version of the program, a file HelloKt.class
was generated. However, in the mixed Java and Kotlin Version, only Foo.class
is generated, but there is no HelloKt.class
. This suggests to me that the Kotlin compiler is either not invoked properly, or it fails for some reason without notifying the user.
Any ideas on how this could be fixed? Is this expected to work, or is the Kotlin plugin for Eclipse outdated and broken for newer versions?