0

Problem description: When using the Kotlin compiler (kotlinc) of any version from the command line (not IntelliJ IDEA, but a separate folder with a .bat file), and when specifying multiple libraries (.jar files) using -cp or -classpath, I get the error: "source entry is not a Kotlin file". The problem only occurs when using multiple libraries; if I use a single library, everything works fine.

Environment: windows: cmd, shell, or Runtime.getruntime().exec() in IntelliJ IDEA

Steps to reproduce: I have tried different delimiters (:,;), as well as different cmd/shell/Runtime.getruntime().exec(), tried to use wildcards(*) instead of listing.

Command in shell/cmd:

C:\Users\MSI\Desktop\COMMANDLINE\kotlin-compiler-1.9.0\kotlinc\bin\kotlinc.bat -cp C:/Users/MSI/Desktop/COMMANDLINE/libs/* C:\Users\MSI\Desktop\bbb\kotlin.kt -include-runtime -d C:\Users\MSI\Desktop\bbb\gigga.jar

Code in IntelliJ IDEA:

val command = ProcessBuilder(
    "C:\\Users\\MSI\\Desktop\\COMMANDLINE\\kotlin-compiler-1.9.0\\kotlinc\\bin\\kotlinc.bat",
    "-cp", "C:/Users/MSI/Desktop/COMMANDLINE/libs/*",
    "C:\\Users\\MSI\\Desktop\\bbb\\kotlin.kt",
    "-include-runtime",
    "-d", "C:\\Users\\MSI\\Desktop\\bbb\\gigga.jar"
)
            val start = command.start()
            val code = start.waitFor()

I want the code to be compiled with all the libraries

3
  • I'm not sure if Kotlin supports the syntax for including multiple jars from a directory. I know Java does, but not sure about Kotlin. Have you tried using quotes around the directory and asterisk, i.e. -cp "C:/Users/MSI/Desktop/COMMANDLINE/libs/*"? Commented Sep 5 at 11:07
  • Ok, it looks like Kotlin doesn't support it: discuss.kotlinlang.org/t/… Commented Sep 5 at 11:22
  • @k314159 this helped! true * in "" still doesn't work but listing through ; in "" works. This is completely not obvious and it needs to be spread. Thank you so much! Commented Sep 5 at 15:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.