我试图让包含在样品瓶反射LIB在一个罐子输出反射库,但不能得到它的工作:包括kotlinc
$ kotlinc hello.kt -d hello.jar
$ java -jar hello.jar
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
运行时的lib已丢失,因此让我们来添加:
$ kotlinc hello.kt -include-runtime -d hello.jar
$ java -jar hello.jar
Exception in thread "main" kotlin.jvm.KotlinReflectionNotSupportedError: Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath
现在,运行时的lib包括,但反射LIB丢失,所以让我们指定科特林主目录:
$ kotlinc hello.kt -include-runtime -kotlin-home ~/.sdkman/candidates/kotlin/1.1.1 -d hello.jar
$ java -jar hello.jar
Exception in thread "main" kotlin.jvm.KotlinReflectionNotSupportedError: Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath
反射库仍不包括在内。 kotlinc
帮助列出了“-no-reflect
”选项,所以我假设反射库应该由默认的“-include-runtime
”时,包括设置,但是这似乎并不如此。