%%ほのかちゃん%% -[[Kotlin Programming Language>https://kotlinlang.org/]] --[[Working with the Command Line Compiler>https://kotlinlang.org/docs/tutorials/command-line.html]] -[[サーバーサイドKotlinの導入から一年が経ちました>https://blog.applibot.co.jp/2019/02/06/kotlin-one-year-anniversary/]] - てっくぼっと! -[[なぜサーバーサイドKotlinを導入するのか?>https://blog.applibot.co.jp/2018/01/18/why-introducing-kotlin/]] - てっくぼっと! -[[JavaプログラマのためのKotlin入門>https://qiita.com/koher/items/bcc58c01c6ff2ece658f]] -[[JavaプログラマがKotlinでつまづきがちなところ>https://qiita.com/koher/items/d9411a00986f14683a3f]] -[[JavaプログラマがKotlinで便利だと感じること>https://qiita.com/koher/items/cb91dbbff9b14575f498]] -[[ラブライブ!で学ぶソフトウェア開発入門>http://learn-with-muse.sato-t.net/]] -> [[南ことりと星空凛のKotlin入門>http://learn-with-muse.sato-t.net/?page_id=5080]] *てっとりばやくWindowsのコマンドラインで [#q65e1960] **インストール [#o0216bf0] +Kotlinのコンパイラをインストール(→ [[Working with the Command Line Compiler>https://kotlinlang.org/docs/tutorials/command-line.html]]) +未インストールなら [[Java実行環境>https://java.com/ja/download/]] も用意(Java 8でOK) PS W:\> kotlinc -version info: kotlinc-jvm 1.3.21 (JRE 1.8.0_201-b09) **Hello [#y6421dfc] #highlight(kt){{ fun main(args: Array<String>) { println("Hello, again my old dear place") } }} #highlight(end) PS W:\> kotlinc .\hello.kt -include-runtime -d hello.jar PS W:\> java -jar hello.jar Hello, again my old dear place **ぬるぽ [#h58446bb] #highlight(kt){{ import java.util.Date import java.text.SimpleDateFormat class Person { val firstName: String val lastName: String val birthday: Date? constructor(firstName: String, lastName: String, birthday: Date?) { this.firstName = firstName this.lastName = lastName this.birthday = birthday } fun fullName(): String { return "%s %s".format(this.firstName, this.lastName) } fun age(): Int? { return this.birthday?.let { val sdf = SimpleDateFormat("yyyyMMdd") (sdf.format(Date()).toInt() - sdf.format(it).toInt()) / 10000 } } } fun main(args: Array<String>) { val person1 = Person("Kanata", "Tanaka", SimpleDateFormat("yyyy/MM/dd").parse("2013/12/02")) println("%s (%d)".format(person1.fullName(), person1.age())) val person2 = Person("Kanata", "Tanaka", null) println("%s (%d)".format(person2.fullName(), person2.age())) } }} #highlight(end) PS W:\> kotlinc .\age.kt -include-runtime -d age.jar PS W:\> java -jar age.jar Kanata Tanaka (5) Kanata Tanaka (null)