I want to compile my programs I made in VS Code but I cannot because allegedly
'javac' is not recognized as an internal or external command, operable program or batch file.
Doing some searching around, I feel like as though it should be working:
"java.home":"C:\\\\Program Files\\\\Java\\\\jdk1.8.0_181\\\\bin"
That one didn't work, but I also tried it without "\\\\bin" too and there was no luck to that, either.
I used the command prompt to navigate to the javac file, and alas that is the only known method that works. (However, javac does not work if I change my directory elsewhere.) What do I do? Why is this happening?
JAVA_HOME
should point to the path where your JDK is installed. This is: C:\\Program Files\\Java\\jdk1.8.0_181. After that, you should edit your PATH
environment variable to add the following entry.
Windows:
PATH=%JAVA_HOME%\bin;<rest of current PATH value>
*-nix systems (Linux, Mac):
export PATH=$JAVA_HOME/bin:$PATH
A rough explanation for PATH: is the system environment variable in charge of making executables available through command line. This is why its value needs to contain the bin
folder inside JAVA_HOME
, and JAVA_HOME
value is the path (you may update it to point to a different JDK).
After updating the value of PATH, you may open a terminal (cmd in Windows) and type:
javac -version
You should see an output like this:
javac 1.8.0_181
And now javac
will be available for any application to use it eg VS Code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.