简体   繁体   English

Kotlin SDK 与 Java ZF20E3C5E54C0AB3D375D660B3F896

[英]Kotlin SDK vs Java SDK

In Intellij's project structure settings I have a choice between Java SDK (from OpenJDK) and Kotlin SDK (from Kotlin plugin?). 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? Kotlin 应用程序应该使用哪个,有什么区别?

项目结构截图

If I recall correctly, Kotlin SDK in IDEA is used in non-JVM modules, like Kotlin/JS or Kotlin/Native.如果我没记错的话,IDEA 中的 Kotlin SDK 用于非 JVM 模块,如 Kotlin/JS 或 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).如果您正在为 Kotlin/JVM 开发,您应该在项目结构中选择相应的 JDK 并添加 kotlin-stdlib 作为 Gradle / Maven 中的依赖项,或者如果您不使用任何外部构建系统,则通过 IDEA 助手添加(您将看到“ Kotlin 未配置”栏(如果需要额外设置)。

If you are going to build a Kotlin application, then you should use the Kotlin SDK.如果您要构建 Kotlin 应用程序,那么您应该使用 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. 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?请参阅此常见问题解答: Kotlin 编译成什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM