Using the Android Studio installation to compile simple Kotlin programs via the command line

Hi,

I’m following this Android tutorial to get started with Kotlin. This tutorial makes you write and run simple Kotlin programs in an online editor. I would like to do this locally, however, and compile the programs via the command line.

I have a working installation of Android Studio, including Kotlin. I have added C:...Android StudiopluginsKotlinkotlincbin to my path. Based on this: https://kotlinlang.org/docs/command-line.html#create-and-run-an-application

I now call kotlinc hello.kt -include-runtime -d hello.jar to compile a simple example program. This gives me the following error, however:

'java' is not recognized as an internal or external command, operable program or batch file.

As far as I can tell, I need to make the Java JDK available for this to work, which is where my question comes in: I assume that I have this already as part of my Android Studio setup and that I just need to add something to my path variable. Is that correct? If so, what exactly am I looking for? I haven’t found any obvious directory next to the Kotlin directory.

Edit: Welp, I found it!

Adding C:...AndroidAndroid Studiojrebin to my path worked. Thanks, guys!

submitted by /u/LeCyberDucky
[link] [comments]