Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run the Kotlin REPL kotlinc-jvm or kotlinc

I am completely new to Kotlin, and I am trying to run the Kotlin REPL.

Following this, and considering I am using OS X, and I have tried this:

$ /usr/local/bin/kotlinc-jvm

which is equivalent to:

$ kotlinc-jvm

Then in the following link, I found that a nicer way to run it is:

$ kotlinc

Is there any differences between this two commands, and which one should I choose?

like image 210
lmiguelvargasf Avatar asked May 21 '17 05:05

lmiguelvargasf


People also ask

Does Kotlin compile to JVM?

Each release of Kotlin includes compilers for the supported targets: JVM, JavaScript, and native binaries for supported platforms. These compilers are used by the IDE when you click the Compile or Run button for your Kotlin project.

Does Kotlin compile to Java or bytecode?

Kotlin lets you choose the version of JVM for execution. By default, the Kotlin/JVM compiler produces Java 8 compatible bytecode.

How do I run the Kotlin program in VS code?

Kotlin IDE for Visual Studio Code To use, make sure that JDK 11+ is installed and open a Kotlin file inside a Gradle or Maven project. Support for Kotlin source files with a standalone compiler ( kotlinc ) is experimental. The language server will then automatically launch in the background.


1 Answers

If you look inside the kotlinc-jvm files, they actually just launch the kotlinc that's in the same folder they are in, and pass any arguments they were started with to it:

kotlinc-jvm for Unix:

#!/usr/bin/env bash

# (License here)

DIR="${BASH_SOURCE[0]%/*}"
: ${DIR:="."}

"${DIR}"/kotlinc "$@"

kotlinc-jvm.bat for Windows:

@echo off

rem (License here)

call %~dps0kotlinc.bat %*

I'm not sure why kotlinc-jvm is there in this form, it's basically just a very simple redirect. I'd just use kotlinc.

like image 50
zsmb13 Avatar answered Sep 27 '22 22:09

zsmb13