The java.home variable defined in Visual Studio Code settings points to a missing or inaccessible folder (C:\Users\username\AppData\Local\Programs\AdoptOpenJDK) (WSL)
See original GitHub issueWhen I open VSCode in WSL, it show this notification. Nothing happen when I open VSCode in Windows. I have define JAVA_HOME and JDK_HOME in system varibles. Then define the path of jdk-11/bin in the system path. The problem is VSCode in WSL use the same ‘setting.json’ as VSCode in Windows.
Environment
- Operating System: Windows 10 Education Version 2004 OS Build 19640.1
- Local JDK version: AdoptOpenJDK 11
- Visual Studio Code version: 1.46.0
- Java extension version: 0.8.1
Steps To Reproduce
- Add remote WSL: Ubuntu-20.04 distro
- Install JDK for WSL with
apt install jdk-11-openjdk
- Now install Java Extension Pack for WSL
- When opening the Java Source Code (Maven) then pop up opening that “The java.home variable defined in Visual Studio Code settings points to a missing or inaccessible folder (C:\Users\username\AppData\Local\Programs\AdoptOpenJDK)”
Error Screen when I try to open VSCode in WSL: Ubuntu (https://imgur.com/mbnwBqT)
Nothing happen when I open VSCode in Windows.
Here is my ‘setting.json’ {
"java.home": "C:\\Users\\Huy\\AppData\\Local\\Programs\\AdoptOpenJDK", "java.help.firstView": "gettingStarted", "editor.suggestSelection": "first", "files.exclude": { "\*\*/.classpath": true, "\*\*/.project": true, "\*\*/.settings": true, "\*\*/.factorypath": true }, "[java]": { "editor.defaultFormatter": "redhat.java" }, "java.refactor.renameFromFileExplorer": "autoApply",
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
The java.home variable defined in VS Code settings points to ...
The java.home variable defined in VS Code settings points to a missing folder Environment Operating System: windows 7 64 JDK version: ...
Read more >Java Programming with Microsoft Visual Studio Code
but I got a problem as shown in the above picture. So I tried to set my JDK path in the settings.json file...
Read more >Visual studio code error JAVA_Home is not set and no 'java ...
windows 11:important: if after you follow this video the problem is still not solved, please double check if you install the correct version ......
Read more >Java with Visual Studio code (Vscode) Part 1 | by Tariqul Islam
Figure 1.2 Search For Java Home Configuration of Visual Studio Code ... command to search where is JDK folder, by using `/usr/libexec/java_home -v`...
Read more >Variables reference - Visual Studio Code
json and launch.json to get a full list of predefined variables. Variables scoped per workspace folder. By appending the root folder's name to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
See:
machine-overridable
: https://code.visualstudio.com/api/references/contribution-points@testforstephen above path is valid (on Windows only), which is the default AdoptOpenJDK installation folder in vscode java installer. The problem is,
java.home
should not be shared accross machines (E.g. Windows & WSL). If I remember correctly, we proposed to change scope of settingjava.home
to “machine” before, and that’s exactly for such cases.@nduchuyvp123 In WSL, you may try removing
java.home
from your settings. After that,/usr/lib/jvm/java-14-openjdk-amd64
will take effect automatically.