IntelliJ IDEA 2019.3 Help

Mix Java and Kotlin in one project

Convert a Java file to Kotlin file

  • From the main menu, select Code | Convert Java File to Kotlin File Ctrl+Shift+Alt+K. The resulting Kotlin file appears in place of the original Java file.

Converting Java file to Kotlin

Create Java files in Kotlin projects

  1. Create a new Kotlin-JVM or Kotlin-JavaScript project.

  2. In the Project Tool Window, select the target package or directory, where you want the Java class to be created.

  3. Press Alt+Insert, select Java Class from the popup, select its kind, and specify its name.

Create Kotlin files in Java projects

  1. In a Java project, select the target location, press Alt+Insert and choose Kotlin file from the popup.

  2. If this is first time you create a Kotlin file in a Java project, the banner informs you about the problem.

    Click the link Configure, and select the desired configurator.

  3. In the Create Kotlin Java Runtime Library dialog that opens, do the following:

    • Choose the modules to configure (if there are several modules in a project)

    • Specify which Kotlin runtime library should be used.

Note that in the future the configuration action is not required.

Last modified: 20 March 2020