Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Programming with Microsoft Visual Studio Code

I downloaded language support for Java by Red Hat in Microsoft Visual Studio Code, enter image description here

but I got a problem as shown in the above picture.

So I tried to set my JDK path in the settings.json file in VSCode:

"java.home": "C:/ProgramFiles/Java/jdk1.8.0_111"

But the problem is still not solved.

Do you know how to solve this problem?

like image 694
구지훈 Avatar asked Feb 20 '17 09:02

구지훈


People also ask

Can I use Visual Studio code for Java?

You can use VS Code to read, write, run, and debug Java source file(s) without creating a project. VS Code for Java supports two modes, lightweight and standard.

Is Vscode good for Java development?

Overall, Visual Studio Code is very good as a Java IDE if you install the Extension Pack for Java. It's merely OK as a Java editor without the extension pack, as becomes obvious when you run Visual Studio Code for the Web.


3 Answers

You have to restart VS Code after entering the java.home variable in the settings file.

Alternatively, setting that variable isn't even required. You can remove it from your settings and VS Code will automatically check your user/system environment variables for JDK_HOME and JAVA_HOME.

See "Setting the JDK" at https://marketplace.visualstudio.com/items?itemName=redhat.java

For information on how to set the environment variables, see Environment variables for java installation

like image 178
FrederikVH Avatar answered Oct 21 '22 00:10

FrederikVH


you should change the path to be like this:

"java.home":"C:\\Program Files\\Java\\jdk1.8.0_111"
like image 43
Zaher88abd Avatar answered Oct 21 '22 00:10

Zaher88abd


My Visual Studio Code is set to use the 32 bit version of JDK

A default java.exe is installed in your %SYSTEMROOT%\System32

Check java version from command line:

java -version

You might need to add your version to PATH:

set PATH=%PATH%;C:\Program Files (x86)\Java\jdk1.8.0_111\bin

And set your system JAVA_HOME:

setx -m JAVA_HOME "C:\Program Files (x86)\Java\jdk1.8.0_111"

Restart cmd and try:

echo %JAVA_HOME%

Restart Visual Studio Code and be happy.

Use set instead of setx for local user.

like image 36
profimedica Avatar answered Oct 20 '22 23:10

profimedica