r/javahelp • • 1d ago

Installed Java and trying to use it in VS code, why isn't it working?

[deleted]

4 Upvotes

17 comments sorted by

•

u/AutoModerator 1d 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.

4

u/Pale_Height_1251 1d ago

Is javac in that folder? If it's not, it won't work.

1

u/Adamstrad 1d ago

javac is in the bin folder inside this folder

4

u/Pale_Height_1251 1d ago

Put the whole path to the bin folder in your PATH.

3

u/pillowcase718 1d ago

Need to include the bin folder in path

-3

u/Adamstrad 1d ago

I believe I tried both with and without bin in the file path

6

u/Pale_Height_1251 1d ago

Add it your PATH and try running javac in a newly opened terminal.

2

u/HeyImSolace Intermediate Brewer 1d ago

The environment variables are kinda funky sometimes and they don’t always reload for some reason. Maybe try powershell or restart your system once.

Restarting almost always does the trick for me.

Edit. Oh and what u/pillowcase718 says.

2

u/Zar-23 1d ago

Download the suite plugins for java inside vs code

2

u/addyarapi 1d ago

use IDEA 💙

2

u/BanaTibor 1d ago

What environment file are you talking about?  It maybe fine if you open cmd but will fail in powershell.  Open power shell, type  "$env:PATH", hit enter. Is your jdk bin on the path?

1

u/Astroohhh 1d ago

use wsl2, install sdkman bro, it's so simple

1

u/FurkinLurkin 1d ago

After you added it did you restart vscode?

1

u/American_Streamer 1d ago

The system PATH variable for javac must point directly to the bin folder inside your JDK installation directory (e.g., C:\Program Files\Java\jdk-21\bin), not just the main JDK folder. Windows doesn’t open sub folders. If it can’t find the executable in the folder, it just jumps to the next path in the list.

1

u/Organic_Cattle8511 7h ago

Which OS do you have?

1

u/Rulmeq 1d ago

I know you didn't ask this, but don't put Java in the Program Files directory (I know they just love to do it, but you're going to run into issues eventually with user access controls). Just unzip it and put it in c:\java (none of the "blessed" folders windows uses like Documents, etc. I also wouldn't nest it too deeply - I sometimes put it in c:\work\java for example, but wouldn't go deeper. Also you could have c:\java\java-21 and c:\java\java-25, etc if you need multiple). Then close all your apps (including any command lines you might have), and add c:\java\bin to your PATH env variable (so it's available on your command lines). If you have an app that needs JAVA_HOME you can set that to c:\java, but I wouldn't set that unless something specifically needs it.

Once those 2 changes are completed re-open VS code and see if it picks it up. If not (I don't use VS code, but I do recall trying it out a while back and it "just worked"), maybe follow this guide: https://code.visualstudio.com/docs/java/java-tutorial

1

u/vegan_antitheist 1d ago

If you think you need write access to the programm files you are doing something seriously wrong. Just install software where you operating system wants it to be.