scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

Packaging a simple Java app with --jvm 8 --server=false fails

Open alexarchambault opened this issue 2 years ago • 2 comments

Repro:

$ cat > Test.java << EOF
public class Test {
  public static void main(String[] args) {
    System.out.println("Test");
  }
}
EOF

$ scala-cli compile --jvm 8 --server=false Test.java
javac: invalid flag: --release
Usage: javac <options> <source files>
use -help for a list of possible options
Compilation failed

alexarchambault avatar Jun 08 '22 13:06 alexarchambault

I think this could be fixed by returning a sensible value here.

alexarchambault avatar Jun 08 '22 13:06 alexarchambault

I'm getting a similar error but it's not specific to packaging in my case Given a scala file, e.g.

// Tmp.scala

object Foo

when on JVM 8

$ java -version
openjdk version "1.8.0_282"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_282-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.282-b08, mixed mode)

compiling the file with specific scala version and disabled server causes a crash, e.g.

$ scala-cli compile Tmp.scala -S 3.1.1 --server=false
8 is not a valid choice for -release
  scalac -help  gives more information
Compilation failed

I'm using scala-cli v0.1.14

prolativ avatar Sep 15 '22 13:09 prolativ

We should not add the -release flag for Java as this can be handled by the forked compiler in Bloop. We just need to make sure that proper Java is set in the json configuration.

tgodzik avatar Sep 20 '23 09:09 tgodzik