0

Using Eclipse 2018.12, I've installed the Eclipse Kotlin plugin (0.8.20.20200316-1305), created a Kotlin project (using the "New..." options under "Kotlin") and wrote a "Hello World!" program:

Test.kt:

fun main() = System.out.println("Hello World!")

enter image description here

However, when I try to run it I get the message

Error: Could not find or load main class TestKt
Caused by: java.lang.ClassNotFoundException: TestKt

Upon further inspection it seems the class has never been compiled. There is no corresponding .class file anywhere. Under the project directory I see Eclipse configuration directory .settings and files .project and .classpath. Besides that, I have an empty bin directory and a src directory with Test.kt only.

I found two similar questions about this in SO: In Unable to Run Kotlin Application in Eclipse, the accepted answer simply indicates working with a new version of Eclipse and Kotlin plugin, both older than what I have now. Besides, the problem may have been solved in that case due to a new installation rather than the version. Kotlin - Error: Could not find or load main class _DefaultPackage is quite old and the accepted answer does not apply anymore. It was about not naming the main class properly, but in my case there is not even a byte code file to be found.

Running "Project -> Compile Kotlin classes" had no effect.

How can I get this simple example to run?

Update: I've updated to 2020-06 (not that it should matter since Eclipse Kotlin lists 2018-12 in its requirements) and replaced Zuly by AdoptOpenJDK HotSpotJDK 11. The error persists. The Eclipse log does not show any related messages.

Update 2: re-created the project in a brand-new workspace but the problem persists.

user118967
  • 4,895
  • 5
  • 33
  • 54
  • 1
    I guess you mean Eclipse 2018-12 which is 6(!) releases behind. Please upgrade or name the technical reasons that prevent you from doing so. Maybe your issue is caused by an (also outdated?) Zulu JRE/JDK (see e.g. [here](https://youtrack.jetbrains.com/issue/KT-32145)). Do you face the same issue with a [AdoptOpenJDK HotSpot JDK](https://adoptopenjdk.net/)? If none of this helps, look at the Eclipse Error log for more details. – howlger Jun 28 '20 at 07:57
  • I've updated to 2020-06 (not that it should matter since Eclipse Kotlin lists 2018-12 in its requirements) and replaced Zuly by AdoptOpenJDK HotSpotJDK 11. The error persists. The Eclipse log does not show any related messages. – user118967 Jun 28 '20 at 16:42

0 Answers0