Kotlin教程:Hello World程序(命令行)

2020-04-1911:48:45编程语言入门到精通Comments1,482 views字数 449阅读模式

编写Kotlin程序,可以使用任何文本编辑器,如:Notepad++。 将以下代码放入任何文本文件并保存。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/18223.html

fun main(args: Array<String>){  
    println("Hello World!")  
}
Kotlin

保存上面代码到文件:hello.kt,Kotlin文件的扩展名是.kt文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/18223.html

1. 编译Kotlin文件

打开命令提示符并转到存储文件的目录位置。 使用以下命令编译hello.kt 文件。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/18223.html

$ kotlinc hello.kt -include-runtime -d hello.jar

执行上面命令,得到以下结果 -
Kotlin教程:Hello World程序(命令行)文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/18223.html

2. 运行Kotlin文件

要运行Kotlin .jar(生成的hello.jar)文件,请运行以下命令。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/18223.html

$ java -jar hello.jar

执行上面命令,得到以下结果 -文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/18223.html

//原文出自【易百教程】,商业转载请联系作者获得授权,非商业转载请保留原文链接:https://www.yiibai.com/kotlin/kotlin-hello-world-program-command-line.html文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/18223.html

文章源自菜鸟学院-https://www.cainiaoxueyuan.com/ymba/18223.html
  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/ymba/18223.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定