I introduce the way to use Kotlin in terminal. Thanks for that, we can use interpreter of Kotlin, which we can often see in LL.
The way I introduce can be used in system with Unix Base, also in OS X.
Procedure
- Install SDKMAN!
- Command
-
|
curl -s https://get.sdkman.io | bash |
- Output
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
Looking for a previous installation of SDKMAN... Looking for unzip... Looking for zip... Looking for curl... Looking for sed... Installing SDKMAN scripts... Create distribution directories... Getting available candidates... Prime the config file... Download script archive... ######################################################################## 100.0% Extract script archive... Install scripts... Set version to 5.5.13+272 ... Attempt update of interactive bash profile... Added sdkman init snippet to /home/user/.bashrc Attempt update of zsh profile... Updated existing /home/user/.zshrc All done! Please open a new terminal, or run the following in the existing one: source "/home/user/.sdkman/bin/sdkman-init.sh" Then issue the following command: sdk help |
- Install Kotlin compiler and interpreter.
- Command
-
- Output
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
==== BROADCAST ================================================================= * 04/12/17: Gradle 4.4-rc-6 released on SDKMAN! #gradle * 30/11/17: Gradle 4.4-rc-5 released on SDKMAN! #gradle * 29/11/17: Groovy 3.0.0-alpha-1 released on SDKMAN! #groovylang ================================================================================ Downloading: kotlin 1.2.0 In progress... ######################################################################## 100.0%j Installing: kotlin 1.2.0 Done installing! Setting kotlin 1.2.0 as default. |
- Make it available to use Kotlin. If you relaunch shell, you don’t have to execute the following command.
- Command
-
|
source "/home/user/.sdkman/bin/sdkman-init.sh" |
Kotlin Interpreter
With command kotlinc
, you can launch Kotlin interpreter.
Example
|
Welcome to Kotlin version 1.2.0 (JRE 1.8.0_151-8u151-b12-0ubuntu0.17.04.2-b12) Type :help for help, :quit for quit >>> 4 + 1 5 >>> println("hello") hello >>> |
When you end it, type :quit
and enter key, or Ctrl + D.
kotlinc file_path.kts [args...]
executes Kotlin script.
Readers who viewed this page, also viewed:
A Life Summary of an Gypsy