我試圖讓包含在樣品瓶反射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
」時,包括設置,但是這似乎並不如此。