Debug java in vscode

邱秋 • 2025年08月13日 • 阅读:21 • java vscode

My computer is Mac M1.

show all the java version

/usr/libexec/java_home -V

we can see :

Matching Java Virtual Machines:
    17.0.11 (x86_64) "Homebrew" - /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
    1.8.0_391 (x86_64) "Java SE 8" - /Library/Java/JavaVirtualMachines/jdk1.8.0_391.jdk/Contents/Home

because the vscode need v17+ at least , so if you can't found 17+, you can intall it .

install jdk 17 or others.

brew install openjdk@8
brew install openjdk@11
brew install openjdk@17

they can coexist. so don't worry it will confused your envriments.

OK , we edit the vscode configrations .

settings.json

{
  // let Oracle Java extensions LSP to use 17
  "jdk.jdkhome": "/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home",

  // if you project always use the old version 1.8 , you can set this.
  // "jdk.project.jdkhome": "/Library/Java/JavaVirtualMachines/jdk1.8.0_391.jdk/Contents/Home"
}

now, reload the vscode. all done.

我,秦始皇,打钱!