2017-08-07 32 views

回答

1

科特林運行時需要運行,as explained here - 所以我看不出有任何理由它不會被要求編制爲好。我想有沒有免費的午餐:-)

您應該:

  • 在classpath中有無科特林運行。
  • 點到運行位置運行應用程序時,as described on this answer
  • 嵌入應用程序的.jar文件內運行:

$ kotlinc <class name> -include-runtime -d <jar name> $ java -jar <jar name>

+0

其實,我沒有使用作爲後端應用程序,沒有額外的1k方法的奢侈品。不過,我喜歡kotlin的語法,並且仍然想要使用它。 – neworld

+0

@neworld - 那麼你能詳細說明什麼是獨特的用例嗎? –

+3

@neworld你肯定至少需要[運行時庫](https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-runtime/1.1.3-2),雖然不一定是[標準庫]( https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib/1.1.3-2)。 AFAIK沒有辦法。在集成運行時後,[ProGuard](https://www.guardsquare.com/en/proguard)可能有助於減少方法數量。 –