I have created a test project aiming to start with Kotlin in IntelliJ IDEA CE.
The IDE version and the system is 2017.1.4 Build #IC-171.4694.23, built on June 6, 2017 JRE: 1.8.0_112-release-736-b21 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Mac OS X 10.12.4
There is one .kt file with a main function in it. When I right-click on it I can select Run, but I get an error form JUnit: !!! JUnit version 3.8 or later expected.
I figured out it was about missing configuration, but I can't set up a proper one for Kotlin as well. Namely it requires a 'main class', which I don't have. Setting package name instead, as some other discussions suggest didn't help either.
What is the proper configuration for Kotlin in IDEA?
Thanks!
When your project is set up correctly, make sure that your main function is called "main" and has a parameter of type Array<String> . Next to it a Kotlin "K" will appear, which you can click on to run your main function.
IntelliJ IDEA provides first-class support for Kotlin. It includes Kotlin-specific project templates, coding assistance, refactorings, debugging, analysis tools, and so on.
Coming from a Java background, I instinctively put the main function inside a class. Then IntelliJ wouldn't let me run it. After taking the main function out of class to the top level, IntelliJ automatically put the green arrow next to the main function and added Run
to the context menu (brought up by right clicking the file).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With