Reputation: 181
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:
I have also tried the directory to my JDK bin with the same results. What am I doing wrong?
Upvotes: 18
Views: 59097
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
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
Reputation: 195
I fixed the issue by downloading OpenJDK from Red Hat openjdk and placing the extracted file in directory C:\ as in the (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
and change workspace settings in VS Code as
Upvotes: 3
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
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
Reputation: 103
Please install Java Debugger like RedHat Extension.
These two things are compulsory to install -
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.
Upvotes: 0