I have a Kotlin source file, but I want to translate it to Java.
How can I convert Kotlin to Java source?
Android Studio does exactly the same to carry out the code conversion from Kotlin to Java. Developers may have many reasons to convert the Kotlin code into Java such as: To integrate features that are easy to implement in Java language. To resolve some performance issue that is difficult to locate in Kotlin.
No, it just needs kotlin-stdlib as a dependency to use it from Java.
In Android Studio 3.0, open a Java file and select Code > Convert Java File to Kotlin File. Or, create a new Kotlin file (File > New > Kotlin File/Class), and then paste your Java code into that file—when prompted, click Yes to convert the code to Kotlin.
As @Vadzim said, in IntelliJ or Android Studio, you just have to do the following to get java code from kotlin:
Menu > Tools > Kotlin > Show Kotlin Bytecode
Decompile
buttonUpdate:
With a recent version (1.2+) of the Kotlin plugin you also can directly do Menu > Tools > Kotlin -> Decompile Kotlin to Java
.
You can compile Kotlin to bytecode, then use a Java disassembler.
The decompiling may be done inside IntelliJ Idea, or using FernFlower https://github.com/fesh0r/fernflower (thanks @Jire)
There was no automated tool as I checked a couple months ago (and no plans for one AFAIK)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With