'Why this error occurs while trying to run java in vs code?

I'm trying to use vs code for java. but get this error while running the code I tried to find the solution but I couldn't find, If any solution available please refer: error



Solution 1:[1]

In a nutshell, you have not installed Java correctly. Finalizing the installation of Java on Windows requires some manual steps. You must always perform these steps after installing Java, including after upgrading the JDK.

  1. Find the Java path; it looks like this: C:\Program Files\Java\jdkxxxx\bin\
  2. Start-menu search for "environment variable" to open the options dialog.
  3. Examine PATH. Remove old Java paths.
  4. Add the new Java path to PATH.
  5. Edit JAVA_HOME.
  6. Close and re-open console/IDE.

Solution 2:[2]

Add the jdk path to your windows system environment.

Then in your VS code workspace settings add the path too.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MingJie-MSFT
Solution 2 Callum Crichton