scalameta / metals-vscode

Visual Studio Code extension for Metals
https://marketplace.visualstudio.com/items?itemName=scalameta.metals#overview
Apache License 2.0
298 stars 75 forks source link

Can't run java 21 via code lens / debug #1435

Closed rochala closed 10 months ago

rochala commented 10 months ago

Describe the bug

To Reproduce Steps to reproduce the behavior:

//> using scala 3
//> using jvm 21

@main def hello =
  val x: com.sun.source.tree.AnyPatternTree = ???
Error log ``` * Executing task: /"opt"/"homebrew"/"Cellar"/"openjdk@17"/"17.0.7"/"libexec"/"openjdk.jdk"/"Contents"/"Home"/"bin"/"java" -classpath "/Users/jrochala/Projects/scala-cli-playground/.metals/.tmp/classpath_27F172492313EEA3967CB8BD059EAD98.jar" hello Error: LinkageError occurred while loading main class hello java.lang.UnsupportedClassVersionError: hello has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0 * The terminal process "/etc/profiles/per-user/jrochala/bin/zsh '-l', '-c', '/"opt"/"homebrew"/"Cellar"/"openjdk@17"/"17.0.7"/"libexec"/"openjdk.jdk"/"Contents"/"Home"/"bin"/"java" -classpath "/Users/jrochala/Projects/scala-cli-playground/.metals/.tmp/classpath_27F172492313EEA3967CB8BD059EAD98.jar" hello '" failed to launch (exit code: 1). * Terminal will be reused by tasks, press any key to close it. ```

Expected behavior

It should work

Screenshots

Installation:

Additional context

Metals uses java from classpath to run the code. It should use the same java that is defined in Scala-CLI using directive

Search terms

tgodzik commented 10 months ago

Duplicate of https://github.com/scalameta/metals/issues/5780