【发布时间】:2017-05-31 16:46:34
【问题描述】:
我是Kotlin 和Gradle 的新手,并尝试遵循these 的步骤,所以我得到了以下2 个文件:
在运行gradle init 之后,我将build.gradle 更改为:
// set up the kotlin-gradle plugin
buildscript {
ext.kotlin_version = '1.1.2-2'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
// apply the kotlin-gradle plugin
apply plugin: "kotlin"
apply plugin: 'application'
mainClassName = "hello.main"
// add kotlin-stdlib dependencies.
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
Hello.kt:
package hello
fun main(args: Array<String>) {
println("Hello World!")
}
然后我运行gradle build 并得到build\classes\main\hello\HelloKt.class
我的问题是:为什么生成的文件是.class 而不是.jar 以及如何获取.jar 文件以及如何运行它,我尝试使用kotlin -classpath HelloKt.class main 运行生成的文件,但出现错误@987654335 @
【问题讨论】: