question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

When 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
  1. Add remote WSL: Ubuntu-20.04 distro
  2. Install JDK for WSL with apt install jdk-11-openjdk
  3. Now install Java Extension Pack for WSL
  4. 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. SharedScreenshot

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:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Eskibearcommented, Jun 22, 2020

C:\Users\Huy\AppData\Local\Programs\AdoptOpenJDK

@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 setting java.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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found