Kotlin SDK vs Java SDK

Viewed 1561

In Intellij’s project structure settings I have a choice between Java SDK (from OpenJDK) and Kotlin SDK (from Kotlin plugin?). Which should I use for Kotlin application and what is the difference?

project structure screenshot

2 Answers

If I recall correctly, Kotlin SDK in IDEA is used in non-JVM modules, like Kotlin/JS or Kotlin/Native. If you are developing for Kotlin/JVM, you should pick corresponding JDK in project structure and add kotlin-stdlib either as a dependency in Gradle / Maven or via IDEA assistant if you don't use any external build system (you'll see "Kotlin not configured" bar if it needs additional setup).

If you are going to build a Kotlin application, then you should use the Kotlin SDK. The Kotlin compiler will let you run, test and debug Kotlin applications by (in your case) converting your Kotlin code into Java (6, but you can explicitly specify another version) bytecode that will then be run by the JVM.

See this FAQ: What does Kotlin compile down to?

Related