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?
You can still compile your projects with Java 8. JDK11 is only required to run vscode-java.
Bring up the Command Palette (Ctrl+Shift+P) and then type java to search for this command. After selecting the command, you will be prompted for the location and name of the project. You can also choose your build tool from this command.
In order to run Java within Visual Studio Code, you need to install a JDK. The Extension Pack for Java supports Java version 1.5 or above. We recommend you to consider installing the JDK from one of these sources: Amazon Corretto.
Android for Visual Studio requires Java Development Kit. Please install it or set Java Development Kit path on Tools->Options->Xamarin->Android Settings menu.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With