Cannot run Kotlin Application in Eclipse

I cannot run Kotlin code from Eclipse. Eclipse always says “Error: Could not find or load main class …”. Even with this simple code:

class Foo {
}

fun main(args: Array<String>) {
}

I use version 0.8.2.v20170314-0957 of the Kotlin plugin in Eclipse Neon (4.6.3).

I’m brand new to Kotlin - I’m a longtime Eclipse and Java user. If Kotlin is to be successful, it needs to run (and well) on Eclipse. So I downloaded Eclipse Oxygen (4.7.0) for Mac OSX. Then installed the Kotlin feature from the Eclipse marketplace. It installed 5 plugins, provider is JetBrains, Version is 0.8.2.v20170314-0957. I created a Kotlin project, added a source file with your code (with an added println(“Hello World”) inside main( ). It ran fine, although I still don’t understand exactly how the Run thing works. The program runs under the “Java Application” category in the run configurations dialog. What is a Kotlin Script Launch Configuration?

Which brings up bigger questions - is JetBrains committed to making Kotlin work well in Eclipse? How and where do we programmers get support? Is the Eclipse plug-in open source? Can we contribute to it? Inquiring minds would like to know.

TIA for whoever addresses these issues.

1 Like

Maybe you have to add Kt to the main class name, in the case of the OP, it should be FooKt.

Anyway, sooner or later, you probably want to switch to gradle (via buildship) or maven etc. anyway to run your programs.

The eclipse plugin is limited (e.g. limited support for templates) but usable. YMMV

Thanks for the response lithom. The Run As… Eclipse popup menu (right click with context on a .kt source file with a main( ) method) creates a Java Run Configuration with the name of the file, capitalizing the first character of the file name, dropping the .kt suffix and adding Kt and putting that into the “Main class:” field in the Java Run Configuration. So your suggested of adding “Kt to the main class name” is the magic elixir. Is this documented anywhere?

I have no interest in learning Gradle. The integration of the build system into Eclipse (for both Java and C, and possibly others) is one of the advantages of Eclipse over XCode et al. I would like to keep the workflow of my programmers as unchanged as possible if we move to Kotlin.

Again I ask -

Is JetBrains committed to making Kotlin work well in Eclipse? How and where do we programmers get support? Is the Eclipse plug-in open source? Can we contribute to it?

If this is not the appropriate forum to get an answer to those questions, please direct to me a place or person that is appropriate.

At this time we’re not actively working on the Eclipse plugin, but we plan to resume active development later this year. You can get support here on these forums or on StackOverflow. The plugin is open-source, and yes, you can contribute.

with maven and spring, try this:
mvn clean package spring-boot:repackage