Will
Will

Reputation: 41

IntelliJ Kotlin - MainKt run/debug configuration unavailable, cannot run project

I'm trying to run a basic Kotlin main file but the problem is I don't have any run/debug configurations available.

My main.kt file is under src>main and is a very simple Helloworld program. See below image. When I enter Add Configuration>Kotlin and type MainKt in Main Class, I get Warning: Class MainKt not found. In previous projects MainKt has been the default and I haven't had to add a configuration manually. Has anyone else come across this issue?

Image of project

Run/Debug Configuration image

Project Structure image

If I hit Run(in toolbar)>Run you can see no available configurations

EDIT: added Main module to source and MainKt class is now available in Add Run/Debug Configuration, but I get the error in below image, "Error: Could not find or load main class MainKt Caused by: java.lang.ClassNotFoundException: MainKt"

Error: Cannot find MainKt

Upvotes: 2

Views: 1356

Answers (1)

somethingsomething
somethingsomething

Reputation: 2189

The source for the class MainKt (main.kt) does not appear to be under your sources root (src/main/kotlin), it's one level up if I interpret the UI of intellij correctly. Try moving it into the kotlin/ directory.

Upvotes: 1

Related Questions