Skip to content
Advertisement

Kotlin and Java project in Eclipse, NoClassDefFoundError, where are the class files?

In this question the basic configuration of Kotlin + Java + Gradle in Eclipse is described. It allows me to create Kotlin code. The Kotlin and Java natures are correctly present. Unfortunately, the code does not run. Not as Kotlin application nor as JUnit test.

When my (i.e. created by me) Kotlin class is called from Java code, it yields a NoClassDefFoundError. When the same test/application is run from Gradle or IntelliJ the code runs correctly.

My investigation thus far has uncovered that the class files in the bin folder are not there to be found when executing.

Using the buildship plugin

The image below shows that the src tree exists. All Java compile classes are in the src tree. The kotlin_bin folder has the correct folders, but no files.

Eclipse bin folder

Using gradlew eclipse and import .project files

This results in the same behavior. I prefer buildship to manage gradle.

Tool versions

I’m using:

  • Eclipse 2019-03 or 2019-06
  • Kotlin eclipse plugin 0.8.17
  • Kotlin-gradle eclipse plugin 0.8.17
  • Buildship plugin 3.1.0
  • Gradle 5.4.1
  • Kotlin 1.3
  • Java 11

Any tips on how to proceed? I would like to be able to run in Eclipse. We’re adding a small Kotlin part to the project, I would prefer not to force my team to switch to IntelliJ.

Advertisement

Answer

This issue seems to be an issue with the Eclipse plugin. See KE-344. All symptoms seem to match.

Advertisement