skip to Main Content

I just downloaded vscode and I’m new to coding. I installed the extensions for java online before downloading vscode itself. I made a project and created a file inside. Visual studio code won’t let me run or debug. It just keeps giving me the same exact error every single time. I already have a JDK downloaded, but it keeps giving me the error. I don’t really understand what is wrong. Could someone please help me? Here are the images of the 2 errors I get:
(https://phpout.com/wp-content/uploads/2023/10/YPJVQ.png)
(https://phpout.com/wp-content/uploads/2023/10/wgo5q.png)

I deleted and reinstalled the red hat JDK many times, but it won’t work. I’m not sure if there is a step I’m missing out or something. I also deleted and reinstalled vscode to try to get it to work, but no luck. I looked at other forums, but I don’t understand what they are saying.

2

Answers


  1. Have you set the jdk path in environment variables? If not then follow the steps below:

    1. In the searchbar of windows (win + S) type environment variables (just typing ‘env’ should show you the required result).
    2. In search results you will get an option saying "Edit system environment variables". Click on that option.
      Search result image
    3. In the new window that pops up you’ll be able to see an option at the bottom right saying "Environment variables", click on that option.
      Environment variables image
    4. You’ll be greeted with a new window which has two sections. Now depending on the type of user you are you will have access to one or both of these sections. In the top section (under user variables) you need to press on new button and enter the variable name as "JAVA_HOME" and value will be the location of the bin folder of your jdk. Something like this
    5. In the second section (under system variables) you have to double click on Path and click on new enter the same path that you entered in the above section and press ok in every window.

    Now you can retry running your program and maybe restart vscode and try again if it doesn’t work.

    Hope it helps, Happy coding 🙂

    Login or Signup to reply.
  2. Check out this link to learn more about using Java in vscode.

    This setting can specify JDK 17 and above versions to activate the Java language server.

        "java.jdt.ls.java.home": "E:\Program Files\Java\jdk-17.0.5",
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search