最近无意中看到kotlin热度挺高的,便想试试写个HelloWord试一试。
工具使用eclipse
一:首先在eclipse中下载kotlin插件
Help -> Eclipse Marketplace... 打开,输入kotlin,点击GO,下载完成重启。
因为直接在Java项目中使用kotlin,所以直接在pom中引引入依赖
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jre8</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
<version>2.8.9</version>
</dependency>
完成后,直接项目中反键新建Kotlin file
输入如下代码
fun main(args: Array<String>) {
print("hellowoed")
}
反键点击Run As -> Kotlin Application 然后便可查看控制台打印结果。
初识kotlin,更多请看http://www.runoob.com/kotlin/kotlin-eclipse-setup.html
多看多学多练,共勉