Skip to content

wingjay/HelloKotlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Install Kotlin on Mac

brew install kotlin

Or

curl -s https://get.sdkman.io | bash
sdk install kotlin

Run kotlin file

Let's say you have a kotlin file called: hello.kt

  1. Compile kt -> .jar
kotlinc hello.kt -include-runtime -d hello.jar
  1. Run by java
java -jar hello.jar

While we can write a shell command to run these two command in one time. Edit your ~/.zshrc as below:

# Kotlin starts
export PATH=$PATH:/usr/local/bin/kotlin
function kotlinr() {
  echo Compiling, please wait...
  kotlinc $1 -include-runtime -d out.jar
  java -jar out.jar
}
# Kotlin ends

Then,

source ~/.zshrc

now you can run kt file as:

kotlinr hello.kt

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages