How to convert a Kotlin source file to a Java source file

activedecay picture activedecay · Jan 23, 2016 · Viewed 243.3k times · Source

I have a Kotlin source file, but I want to translate it to Java.

How can I convert Kotlin to Java source?

Answer

Louis CAD picture Louis CAD · Nov 23, 2016

As @Vadzim said, in IntelliJ or Android Studio, you just have to do the following to get java code from kotlin:

  1. Menu > Tools > Kotlin > Show Kotlin Bytecode
  2. Click on the Decompile button
  3. Copy the java code

Update:

With a recent version (1.2+) of the Kotlin plugin you also can directly do Menu > Tools > Kotlin -> Decompile Kotlin to Java.