Search code examples
javavisual-studio-codevscode-remote

VSCode Java Debugger Version change


I have a problem to change my VSCode Java Debuggeer JVM version. No matter what I did it stucks with 1.8 version. When I check from console I see 11.

gus:(ReadMe-and-configurational-change) ✗  java -version
java version "11.0.16.1" 2022-08-18 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.16.1+1-LTS-1)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.16.1+1-LTS-1, mixed mode)

also updated settings.json from VSCode but no help. When I attach a process for debugging

I see

[Warn] The debugger and the debuggee are running in different versions of JVMs. You could see wrong source mapping results.
Debugger JVM version: 1.8.0_291
Debuggee JVM version: 11.0.16.1
........

Anyone have experience&suggestions on this how to update java debugger version?

I use 1.73.1 VScode Extensions Language Support for Java(TM) by Red Hat 1.13.0

Thanks in advance

~/.vscode-server/data/Machine/settings.json

{ "java.configuration.runtimes": [

{
  "name": "JavaSE-11",
  "path": "~/.sdkman/candidates/java/jdk-11.0.16.1-oracle",
  "default": true
},
{
  "name": "JavaSE-17",
  "path": "~/.sdkman/candidates/java/17.0.5-oracle"
},   ], }

updating settings.json of VSCode as above uninstall install extensions did not work. Clean Workspace refresh I tried everything.

Project is maven managed and I have no issues building through console. And versions are set correctly on POM. Also other IDE's are without problem. I have to use VsCode just for remote development.

Any ideas appreciated a lot.

It is still showing enter image description here


Solution

  • Since it can be useful for someone else just sharing the solution to my problem. As I said the project was correctly getting the toolchain config, building and running with 11 when command ran from console also on other IDE's. Then realized that this is caused by m2e plugin usage of Vscode's Java Plugin.

    Including settings.json alone was not solving the issue.

    So Solution to that include below explicitly in parent pom.

    <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target>