A. Duke
A. Duke

Reputation: 181

Visual Studio Code can't find JDK8

I am currently trying to compile and run Java in VSC using redhat's extention and the code runner extension, though every time I try to "Run code," it tells me "Java runtime could not be located," and in the output: "'javac' is not recognized as an internal or external command, operable program or batch file." So I went into settings to tell VSC the path to my JDK. I went to "Java configuration" and inserted "java.home": C:\Program Files\Java\jre1.8.0_144 into the settings, though it gives me another error stating "Value Expected (2, 18)". This is where I'm stuck currently:

Where I'm Stuck Currently

I have also tried the directory to my JDK bin with the same results. What am I doing wrong?

Upvotes: 18

Views: 59097

Answers (6)

Julio Cesar
Julio Cesar

Reputation: 21

I had the same problem today, after a few hours trying to find why it stoped working, came to my solution. Java updated and there was an empty older vesion folder left in the c:\program files\java, just deleted and everything is working again.

Upvotes: 0

jod
jod

Reputation: 533

For everyone who ended here with an jdk installed through asdf:

It turned out I did not update my JAVA_HOME env variable properly.

Setting it like documented here solved the problem for me: https://github.com/halcyon/asdf-java#java_home

Upvotes: 0

MOHAMMAD WASEEM
MOHAMMAD WASEEM

Reputation: 195

I fixed the issue by downloading OpenJDK from Red Hat openjdk and placing the extracted file in directory C:\ as in the image(I have renamed the file name from "java-1.8.0-openjdk-1.8.0.191-1.b12.redhat.windows.x86_64" to "java-1.8.0-openjdk-1.8.0.191" for simplicity) And change user settings in VS Code as USER SETTINGS and change workspace settings in VS Code as WORKSPACE SETTINGS

Upvotes: 3

Neon
Neon

Reputation: 121

I have faced the same problem if you are on Windows machine then open folder C:\Program Files\Java\ and look for the newest version of JDK in my case it's "jdk1.8.0_144" then enter on the right side following:

`{
     "java.home": "C:\\Program Files\\Java\\jdk1.8.0_144"
 }`

If you don't have at least 1.8 then install a new one! because VS code doesn't support older versions!

Your error says you need to put in double Slashes.

If you are on Linux then use normal slashes "/"

Don't forget to save and restart VS code afterward to apply changes! Have a nice day

Upvotes: 5

abhay tripathi
abhay tripathi

Reputation: 4022

The format of syntax is wrong. Instead of writing -

    "java.home": C:\Program Files\Java\jre1.8.0_144

this should be written -

    "java.home": "C:/Program Files/Java/jdk1.8.0_144"

Use slash (/) instead of backslash () in file path and put quotes around it. Do recheck that jdk 8 or later is installed.

Upvotes: 20

Prasad
Prasad

Reputation: 103

Please install Java Debugger like RedHat Extension.

These two things are compulsory to install -

  1. Language Support for Java(TM) by Red Hat - already installed .
  2. Java Debugger for Visual Studio Code - Install this one .

Here is a shortcut -

vscode:extension/vscjava.vscode-java-pack

Copy and paste above line in the browser address bar and press 'Return(Enter)'. the extension will open in the VSC, Install and reload the editor.

Go to this link

Upvotes: 0

Related Questions