I echoed the commands that are executed in kotlinc
:
[xxxxxxx@uss intro1]$ bash -x ~/Downloads/kotlinc/bin/kotlinc AimToTen.kt
+ cygwin=false
+ case "`uname`" in
++ uname
++ findKotlinHome
++ local source=/users/1/xxxxxxx/Downloads/kotlinc/bin/kotlinc
++ '[' -h /users/1/xxxxxxx/Downloads/kotlinc/bin/kotlinc ']'
+++ dirname /users/1/xxxxxxx/Downloads/kotlinc/bin/kotlinc
++ cd -P /users/1/xxxxxxx/Downloads/kotlinc/bin/..
++ pwd
+ KOTLIN_HOME=/users/1/xxxxxxx/Downloads/kotlinc
+ false
+ '[' -n '' ']'
+ JAVA_OPTS='-Xmx256M -Xms32M'
+ declare -a java_args
+ declare -a kotlin_args
+ '[' 1 -gt 0 ']'
+ case "$1" in
+ kotlin_args=("${kotlin_args[@]}" "$1")
+ shift
+ '[' 0 -gt 0 ']'
+ '[' -z '' -a -n '' -a -x /bin/java ']'
+ declare -a kotlin_app
+ '[' -n '' ']'
+ '[' -n '' ']'
+ KOTLIN_COMPILER=org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
+ java_args=("${java_args[@]}" "-noverify")
+ kotlin_app=("${KOTLIN_HOME}/lib/kotlin-preloader.jar" "org.jetbrains.kotlin.preloading.Preloader" "-cp" "${KOTLIN_HOME}/lib/kotlin-compiler.jar" $KOTLIN_COMPILER)
+ java -Xmx256M -Xms32M -noverify -cp /users/1/xxxxxxx/Downloads/kotlinc/lib/kotlin-preloader.jar org.jetbrains.kotlin.preloading.Preloader -cp /users/1/xxxxxxx/Downloads/kotlinc/lib/kotlin-compiler.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler AimToTen.kt
As you can see in the last line, there is a path to the installation path of kotlinc
. I want to remove them, but failed. Here are some attempts:
failed:
java -Xmx256M -Xms32M -noverify -cp kotlin-preloader.jar org.jetbrains.kotlin.preloading.Preloader -cp kotlin-compiler.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler AimToTen.kt
ok:
java -Xmx256M -Xms32M -noverify -cp /users/1/xxxxxxx/Downloads/kotlinc/lib/kotlin-preloader.jar org.jetbrains.kotlin.preloading.Preloader -cp /users/1/xxxxxxx/Downloads/kotlinc/lib/kotlin-compiler.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler AimToTen.kt
ok:
java -Xmx256M -Xms32M -noverify -cp kotlin-preloader.jar org.jetbrains.kotlin.preloading.Preloader -cp /users/1/xxxxxxx/Downloads/kotlinc/lib/kotlin-compiler.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler AimToTen.kt
ok maybe, because AimToTen.class was generated and could be called:
[xxxxxxx@uss intro1]$ java -Xmx256M -Xms32M -noverify -cp kotlin-preloader.jar org.jetbrains.kotlin.preloading.Preloader -cp kotlin-compiler.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler -cp kotlin-runtime.jar AimToTen.kt
warning: classpath entry points to a non-existent location: /users/1/xxxxxxx/Codes/lib/kotlin-runtime.jar
The last line does not use any path to installation directory. But it echoes an warning
However the .class
file is generated, which means .kt
file was compiled successfully(?).
But why it shows a warning? And are kotlin-preloader.jar, kotlin-compiler.jar, kotlin-reflect.jar and kotlin-runtime.jar
the minimum requirements for compiling .kt
files?
P.S. I want to run class by java -jar ".:kotlin-runtime.jar" <ClassName>
.