I am using IntelliJ IDEA 2021.1 (Community Edition) - Build #IC-211.6693.111, built on April 6, 2021. I created a new kotlin project - project template(JVM): Application, built system: Gradle Kotlin, project JDK:1.8 version 1.8.0_281. In the “scr/main/kotlin” folder, I created a kotlin file with a simple code like "fun main(){println(“Hi!”)}. When I tried to run the file(the build was ok), I got this error: “Could not find or load main class MyAppKt”. What did I do wrong?
Asked
Active
Viewed 401 times
1 Answers
0
Did you also add your main class to the build.gradle file?
mainClassName = "projectPackage.MyAppKt"
I assume if you are adding the MyAppKt file manually it is not added to the build.grale. But clearly more information about the project would help here. Meanwhile check this post Kotlin - Error: Could not find or load main class _DefaultPackage
ksysha
- 312
- 6
- 8