-2

I have JDK11 and JADK8 both installed on my MacOS. I have changed the JDK default version to 1.8 to make sure GlassFish V5 can be run.

However, the change is not taken place at VSCode, and VSCode terminal keeps on showing JDK11 as JAVA version, which is preventing me from running GlassFish server though VSCode.

enter image description here enter image description here

How can I fix this? Thank you

Arvind Kumar Avinash
  • 71,965
  • 6
  • 74
  • 110
rksh
  • 3,920
  • 10
  • 49
  • 68

3 Answers3

0

Here you can choose wich version to install.

enter image description here

Edit : as mentionned here

VS Code does not have built-in support for Java projects. You need to install some Java extensions and configure them to specify the correct Java JDK version, which you can do by either setting the JAVA_HOME environment variable or by setting the java.home setting:

T.K
  • 434
  • 7
  • 14
0

It depends on the value of JAVA_HOME environment variable. Check your JAVA_HOME path in the settings.json file.

enter image description here

If it shows Java11, set JAVA_HOME environment variable as per your requirement and restart VSCode. Check How to set JAVA_HOME in Mac permanently?.

Arvind Kumar Avinash
  • 71,965
  • 6
  • 74
  • 110
  • This worked but it gives the following message `Java 11 or more recent is required to run the Java extension.(Current JDK: /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home)` Anyway to solve that? – rksh Aug 08 '21 at 14:05
  • Great! Now, you need [Is it possible to select JDK 8 for Java project in Visual Studio Code?](https://stackoverflow.com/q/63770624/10819573) and/or [JDK 1.8 not supported by vs code?](https://stackoverflow.com/q/56307730/10819573). – Arvind Kumar Avinash Aug 08 '21 at 14:07
0

Java extension needs jdk11 or recent version to support, so it's required to set jdk11 as java.home in vscode, but it's also achievable to specify other jdk version for project.

Open Command Palette and Search Java: Configure Java Runtime.

Choose JDK8 for Project JDKs.
Choose JDK11 or recent version as Java Tooling Time.

Don't forget to reload window to make the change effective.

enter image description here

Detailed information please view official docs: Configure JDK

Molly Wang-MSFT
  • 7,943
  • 2
  • 9
  • 22