redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.08k stars 438 forks source link

The java.home variable defined in VS Code settings points to a missing folder #690

Closed danieltedev closed 5 years ago

danieltedev commented 6 years ago

The java.home variable defined in VS Code settings points to a missing folder

Environment
Steps To Reproduce

user settings vscode: "java.home": "C:\Program Files\Java\jdk1.8.0_161" system environment variable: name variable = JAVA_HOME / value variable = c:\Program Files\Java\jdk1.8.0_191 system environment variable: name variable = JDK_HOME / value variable = c:\Program Files\Java\jdk1.8.0_191

error: The java.home variable defined in VS Code settings points to a missing folder

I have already taken a look at all the problems already reported but I did not find a solution, can you help me?

snjeza commented 6 years ago

You can try the following;

"java.home": "C:\\Program Files\\Java\\jdk1.8.0_191\\",
Inukares commented 6 years ago

Below worked for me.

"java.home": "C:\\Program Files\\Java\\jdk1.8.0_191",

As vsCode docs say, on Windows you have to escape "\" character while setting java.home json in vsCode's settings.

danieltedev commented 6 years ago

good morning, i already tried "java.home": "C:\Program Files\Java\jdk1.8.0_191\" but not working @snjeza.... thank for helping me!!!

I going continue trying

sorry for my english

fbricon commented 6 years ago

@danieltedev did you try to use double backslashes? (\\)

danieltedev commented 6 years ago

sorry my message removed the double backslashes, but yes, I used double backslashes

fbricon commented 6 years ago

have you tried using forward slashes (/) instead? "java.home": "C:/Program Files/Java/jdk1.8.0_191"?

Inukares commented 6 years ago

You say that you've set the settings in vsCode to point to \jdk1.8.0_161, but in env variable you have \jdk1.8.0_191 Maybe you wrote wrong sdk version?

danieltedev commented 6 years ago

I sorry, I should have talked about all the tests I did....

I already tried: "java.home": "C:\Program Files\Java\jdk1.8.0_191\", "java.home": "C:\Program Files\Java\jdk1.8.0_191" "java.home": "C:/Program Files/Java/jdk1.8.0_191/", "java.home": "C:/Program Files/Java/jdk1.8.0_191",

Agredo commented 5 years ago

I have the same problem. Cant use Java in VS Code.

danieltedev commented 5 years ago

Sorry I figured out what I did wrong, I put the settings inside the workspace and for this reason it was not working.

apsmono commented 5 years ago

what did you mean by this??

Sorry I figured out what I did wrong, I put the settings inside the workspace and for this reason it was not working.

vintprox commented 5 years ago

Bruh. I set following in User Settings:

    "java.home": "C:\\Program Files\\RedHat\\java-1.8.0-openjdk-1.8.0.222-4"

But it still cannot locate actually installed JDK.

Using path to Java SE Development Kit C:\\Program Files\\Java\\jdk-13.0.1 doesn't help either.

iaxat commented 4 years ago

Same problem

ditordccaa commented 4 years ago

I had the same problem. What I did additionally is setting the environment variable too. export JAVA_HOME=C:/Program Files/Java/jdk1.8.0_131 and it worked. Cheers,

fcastresana commented 4 years ago

Hi! i had the same problem. try downloading this AdoptOpenJDK\jdk-11.0.8.10-hotspot\ then configure your system variables like this tutorial https://javatutorial.net/set-java-home-windows-10 other important thing check if you have two java versions installed and uninstall the one you dont need.

alishah730 commented 4 years ago

this is my java home in mac and still getting same issue "java.home": "/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home"

image

veedata commented 4 years ago

this is my java home in mac and still getting same issue "java.home": "/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home"

image

Hey, i was facing the same issue, i tried all the solutions above but they did not work and still gave an error. It seems to be a problem with the Red Hat extension. It required Java 11 minimum. To bypass this i went to a version of the extension where this wasn't the case What fixed it for me was downgrading to v0.62.0 (maybe it works in a more recent )

This is not a fix in itself, so, i hope someone does find a better way out, but till that point in time, this is a monkey fix

fbricon commented 4 years ago

Since vscode-java 0.65.0, "java.home" needs to point to a JDK 11 installation, so the Java Language Server can run.

You can still use a JDK 1.8 (actually anything from 1.5 to 14) to compile your projects, if you configure the "java.configuration.runtimes" preference, as documented in https://github.com/redhat-developer/vscode-java/wiki/JDK-Requirements.

iaxat commented 4 years ago

I have found the solution for this issue that worked for me, I installed the Java.deb file and then the issue got removed.

https://gofile.io/d/lNjQkz

thanhle7 commented 4 years ago

Better using java.home settings by workspace. Given vscode for mobile app dev using react-native with 32-bit JDK but some Java apps using 64-bit JDK version of 11 or later, workspace settings should help.

bphariharan1301 commented 3 years ago

You can try the following;

"java.home": "C:\\Program Files\\Java\\jdk1.8.0_191\\",

are you sure that it's working?? Since, i tried and its not working..

victorbombella commented 3 years ago

I just had the same problem and I noticed that the problem was in the workspace configuration, so, you need to change the "java.home" path in both, User json and Workspace json, following the rule of using "\" (doble slash) and setting the same path in both.

LaoLiulaoliu commented 3 years ago

I met the same problem too in win10 with settings.json "java.home": "C:\Program Files\Java\jdk-11.0.10",

Eskibear commented 3 years ago

@LaoLiulaoliu

following the rule of using \\ (doble slash)

@bphariharan1301 As mentioned in https://github.com/redhat-developer/vscode-java/issues/690#issuecomment-673376270 , it requires JDK 11+ to launch the language server itself.

Thengsenghong commented 7 months ago

Bruh. I set following in User Settings:

    "java.home": "C:\\Program Files\\RedHat\\java-1.8.0-openjdk-1.8.0.222-4"

But it still cannot locate actually installed JDK.

Using path to Java SE Development Kit C:\\Program Files\\Java\\jdk-13.0.1 doesn't help either.

java.home is deprecated please use "java.jdt.ls.java.home" in stead.

huykon commented 6 months ago

I'm facing with same issue on my ubuntu vscode