Can’t run kotlin file in IDEA and can’t beat that error.
Unfortunately we can’t help you if you don’t provide any information about the details of your problem. How do I ask a good question? - Help Center - Stack Overflow is a great introduction to asking technical questions in a way that makes it easy for others to answer them.
- Download and install IntelliJ IDEA
- Create any Kotlin file with “fun main(args: Array)” method
- Run it and you’ll figure that error.
As you can imagine, I’ve done this quite a few times and I haven’t seen the error. Could you please attach a screenshot, at least?
Create new project:
Create java class:
![](https://global.discourse-cdn.com/business5/uploads/kotlinlang/original/2X/4/4cb93d874706d9391facad54e3f07cff48c3c428.png)
Convert it to Kotlin:
![](https://global.discourse-cdn.com/business5/uploads/kotlinlang/original/2X/3/32425b937f12e60c4aa50710a2a69749449002da.png)
Run the file:
Got an error:
Open dialog “run/debug configuration”, figure JUnit test:
Remove it, save dialog:
second run, same error, JUnit test self-restore, like never deleted:
What IDEA run:
“C:\Program Files\Java\jdk1.8.0_121\bin\java” -ea -Didea.test.cyclic.buffer.size=1048576 “-javaagent:C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2017.1\lib\idea_rt.jar=53650:C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2017.1\bin” -Dfile.encoding=UTF-8 -classpath “C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2017.1\lib\idea_rt.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2017.1\plugins\junit\lib\junit-rt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\rt.jar;C:\Users\JavaD\Desktop\JavaErrorTest\out\production\JavaErrorTest;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2017.1\plugins\Kotlin\kotlinc\lib\kotlin-runtime.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2017.1\plugins\Kotlin\kotlinc\lib\kotlin-reflect.jar” com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 JavaErrorTest
Looks like Idea thinks this is a JUnit test because the class name ends with “Test”. You should probably avoid that.
There is indeed a long-standing bug in IntelliJ IDEA that causes the class to be incorrectly detected as a JUnit test in this scenario. The name of the class doesn’t matter. We’ll fix the bug in a future update. To run your code, instead of right-clicking the editor tab, right-click the “main” method and select “Run”, or use the gutter icon to run it.
excellent - thx!!!
took me a bit to figure that out
I know this is a very old topic, but I just wanted to say that it appears the name is actually very much making a difference. My test was called AppNameTest before and I renamed it to SomeThingInstrumentedTest, and it immediately moved it under Android Instrumented Tests group in config, and I stopped having the JUnit version error.