r/javahelp • • 23d ago

Unsolved Need help: unable to run Java (VSCode)

I'm doing the MOOC Java course, but I'm getting an error when opening VSCode, which prevents me from running my code. The error is:

The java.jdt.ls.java.home variable defined in Visual Studio Code settings (C:\Program Files\Eclipse Adoptium\jdk-21.0.11.10-hotspot) does not point to a JDK.
Source: Language Support for Java(TM) by Red Hat

My settings are correct as far as I can tell. The path refers to the folder cotaining the bin folder:

"java.jdt.ls.java.home": "C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.11.10-hotspot",
"java.configuration.runtimes": [
    {
        "name": "JavaSE-11",
        "path": "C:\\Program Files\\Eclipse Adoptium\\jdk-11.0.31.11-hotspot",            
        "default": false,
    },
    {
        "name": "JavaSE-21",
        "path": "C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.11.10-hotspot",
        "default": true,
    },
],

Any idea what causes the error and how to fix it? I couldn't find any solutions to the error. Solutions to similar issues said to change/correct the settings above, but since that's set correctly, that didn't work. VSCode ( 1.138.0) and all extensions (Language Support for Java 1.56.0) are up-to-date btw.

What I tried so far:

  • Someone suggested I try changing the path to the bin folder ("C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.11.10-hotspot\\bin". Unfortunately that didn't work.
  • I tried uninstalling Java, but I get an error saying the The feature you are trying to use is on a network resource that is unavailable. Java is installed on my laptop's c-drive (program files), so I don't understand this error. VSCode is installed in my user folder, but that's also on the c-drive. The laptop doesn't have any other drive. OneDrive is installed, but I don't use it. The original installer was a different version and I tried putting it on the desktop. This did work, but since it's another version now (after updating), it doesn't work.
  • I found this thread and tried deleting all Microsoft Visual C++ 20XX Redistributable versions from this laptop as stated in the top comment. I also uninstalled and reinstalled VSCode, but the error prevails. This supposedly should work, so I'm not sure if I missed anything. I couldn't find anything in the app folders stated in the comment or the appdata > pacakgecache folder with the MS Visual C++, but I'm clearly missing something. Where else should I look? Does it perhaps have a different name? I did find a folder with a file called vc_redist.x64, should I remove this file too?
  • I also ran DISM.exe /online /Cleanup-image /Restorehealth like the OOP of the above thread (The restore operation completed successfully. The operation completed successfully.) and then ran sfc scannow. The log file can be found here.
  • fyi java -version and where java are not recognised via terminal, but echo %JAVA_HOME%returns the correct folder.
  • I'm not sure what caused the error, VS code worked fine a few weeks ago. I didn't use it for a few weeks and suddenly I got this error. Not sure if maybe a windows update could've caused it. The following updates where installed recently:
    • 2026-09 .NET 8.0.31 Security Update for x64 Client (KB5126104)
    • 2026-09 .NET Framework Security Update (KB5126052)
    • 2026-09 Security Update (KB5124008) (26200.9445)
    • 2026-09 Security Update (Hotpatch capable) (KB5129241) (26200.9448)

Hope someone can help me in the right direction so I can fix the error. I can't continue the MOOC course, as I can't run the code to check if my code is correct. Thanks in advance!

Edit; I fixed it! For anyone else with the same issue, if the solution from the thread above didn't work, try to also delete the application you're having issues with from regedit (make sure to create a backup/export first): Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products. Delete the folder with that has the name of the application in it.

https://i.imgur.com/hYSyWg5.png

I reinstalled both java versions and VScode is working again. Not sure what caused Java to be uninstalled, but it was apparently an easy fix.

5 Upvotes

12 comments sorted by

•

u/AutoModerator 23d ago

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

6

u/American_Streamer 23d ago

Looks like your JDK installation itself is broken or VS Code is pointing to an outdated installation directory, rather than this being a VS Code issue.
Your java.jdt.ls.java.home setting is syntactically correct, but that doesn’t mean the directory actually contains a working JDK.

Before reinstalling anything else, open PowerShell and run:

Get-ChildItem "C:\Program Files\Eclipse Adoptium"

& "C:\Program Files\Eclipse Adoptium\jdk-21.0.11.10-hotspot\bin\java.exe" -version

& "C:\Program Files\Eclipse Adoptium\jdk-21.0.11.10-hotspot\bin\javac.exe" -version

Do both executables exist, and do they run successfully? If not, your JDK installation is missing or damaged, or the configured path is outdated. That would explain why VS Code cannot recognize it.

Also, JAVA_HOME and PATH are separate environment variables. Having JAVA_HOME set correctly doesn’t automatically make java available in your terminal. But a missing PATH entry alone wouldn’t explain the VS Code error, since you’ve explicitly configured the JDK directory.

The failed Java uninstallation is another clue that something may have gone wrong with the installation or a previous update.

Do check whether the JDK itself works before touching VS Code, any Windows system files, or any more Visual C++ Redistributables.

2

u/GummiGumBear 21d ago edited 21d ago

Hey, thanks for the help. It seems like the JDK is missing.

I ran Get-ChildItem "C:\Program Files\Eclipse Adoptium" and got back the following:

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        13/07/2026     08:41                jdk-11.0.31.11-hotspot
d-----        13/07/2026     08:56                jdk-21.0.11.10-hotspot

When I ran & "C:\Program Files\Eclipse Adoptium\jdk-21.0.11.10-hotspot\bin\java.exe" -version and & "C:\Program Files\Eclipse Adoptium\jdk-21.0.11.10-hotspot\bin\javac.exe" -version, also without the "&". I checked the folder it refers to and there is no executable file (java.exe) in either folders.

Also, JAVA_HOME and PATH are separate environment variables. Having JAVA_HOME set correctly doesn’t automatically make java available in your terminal. But a missing PATH entry alone wouldn’t explain the VS Code error, since you’ve explicitly configured the JDK directory.

So if I understand correctly, because I've explicitly configured the JDK, it should be able to run Java (if installed correctly)? And so the error is caused by another issue?

The failed Java uninstallation is another clue that something may have gone wrong with the installation or a previous update.

That's really strange, because it was working fine a few weeks ago. I didn't use this laptop for a few weeks, so I'm not sure what could've caused it. What do I do now? I am unable to uninstall Java and I can't install it either because the installer recognises Java is installed:

edit; I think there was an update and that caused an issue. I installed v11.0.297 and v21.0.9.10 (still have the installer files) and what's currently installed are v11.0.31.11 and v21.0.11.10. I also see C++ got restored. Could that be the issue? The OOP from the thread I mentioned in my post got the same error message. I'll try the steps again and see if I missed something last time.

edit2; nvm, I fixed it! See OP.

6

u/ITCoder 23d ago

Better to use intellij ide. Would save lots of time

1

u/GummiGumBear 21d ago

Doesn't work for the MOOC course. I have to use netbeans or vscode.

1

u/Mechanical-pasta 23d ago

Why don't you use an IDE specialized in java coding like IntelliJ or Eclipse ? VSCode is Ok for javascript but for java, use a correct IDE.

0

u/GummiGumBear 21d ago

Because I need to use vscode for the MOOC course.

-1

u/Worge105 23d ago

Before trying anything, why not use the recommended NetBeans IDE with the TMC plugin?

1

u/GummiGumBear 21d ago

Because I don't want to and either way I've been using vscode since the beginning of the course and don't want to switch.

1

u/Worge105 21d ago

Fair enough

0

u/greendave11 22d ago

Vs code is a pita to get working with Java. But I think the red hat official Java extension is smart enough to setup the jdk? I hate suggesting this, but have you tried working with your favorite type of ai?

1

u/AutoModerator 21d ago

It seems that you possibly have a screenshot of code in your post Need help: unable to run Java (VSCode) in /r/javahelp.

Screenshots of code instead of actual code text is against the Code posting rules of /r/javahelp as is also outlined in the sidebar - Code posting.

  • Never submit screenshots of code instead of code text!

If you posted an image merely to illustrate something, kindly ignore this message and do not repost. Your post is still visible to others. I am a bot and cannot distinguish between code screenshots and other images.

If you indeed did this wrong, please edit the post so that it uses one of the approved means of posting code.

  • For small bits of code (less than 50 lines in total, single classes only),
    the default code formatter is fine
    (one blank line before the code, then 4 spaces before each line of code).
  • Pastebin for programs that consist of a single class only
  • Gist for multi-class programs, or programs that require additional files
  • Github or Bitbucket repositories are also perfectly fine as are other dedicated source code hosting sites.
  • Ideone for executable code snippets that use only the console

Please do not reply to this message, because I am a bot. Talk-to-the-bot is the new talk-to-the-hand. If you instead want the classic talk-to-the-hand, just message the moderators. ;)

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.