IntelliJ IDEA 2017.3 Help

Mixing Java and Kotlin in One Project

On this page:

Creating Java files in Kotlin projects

To create a Java file in a Kotlin project, follow these steps

  1. Create a Kotlin project as described in the sections Creating Kotlin-JVM Project or Creating 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, choose Java Class from the pop-up menu, select its kind, and specify its name.

Creating Kotlin files in Java projects

To create a Kotlin file in a Java project, follow these steps

  1. In a Java project, select the target location, press Alt+Insert and choose Kotlin file from the pop-up menu.
  2. If this is first time you create a Kotlin file in a Java project, the banner shows:
    kotlin banner

    Click the link Configure, and select the desired configurator:

    kotlin configurator

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

    • Choose the modules to configure (if there are several modules in a project)
    • Specify which Kotlin run-time library should be used.
    kotlin runtime

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

Last modified: 6 March 2018

See Also