0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

kotlinのシンプルなmain関数内でHello Worldを出力する

Posted at

Homebrewを用いてKotlinをMacにインストールする。

$ brew install kotlin
$ kotlin -version
=> Kotlin version 1.3.61-release-180 (JRE 11.0.1+13-LTS)

KotlinでシンプルなHello Worldを記述する

helloWorld.kt
fun main(args: Array<String>) { 
  println("Hello, World!")
}

Kotlin Compilerで上記ktファイルをコンパイルする

$ kotlinc helloWorld.kt -include-runtime -d helloWorld.jar
$ hello_world ll
-rw-r--r--  1 user staff   1.3M Dec 27 22:34 helloWorld.jar
-rw-r--r--  1 user staff    62B Dec 27 22:33 helloWorld.kt

javaコマンドでjarファイルを実行する

$ java -jar helloWorld.jar
=> Hello, World!

Hello, World!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?