* Take the "\bin" off the string in JAVA_HOME
* Add this to the end of the PATH variable: ;%JAVA_HOME%\bin
* close and restart the command line
* Execute: javac -version
* you should see a version number
All things are lawful, but not all things are profitable.
I'm having the same problem and I attempted Knute's solution but continued to get the same message ('javac' is not recognized...). To make sure I fully understand what you were saying, C:\Program Files\... in the screenshot was supposed to end in "jdk1.8.0_91;%JAVA_HOME%\bin" correct?
I'd never touched the environmental variables before this (didn't even know they existed and I'm not sure what they do either, just trying to be able to compile from the command prompt). I added the file path on my computer for the jdk folder containing the bin folder containing javac and gave it the variable name JAVA_HOME, hoping that following these steps would solve my problem. It didn't. I've done all my previous coding with an IDE and am trying to learn how to compile and run java files from the command prompt. Any help would be appreciated.
Environment variables are global variables that configure your command line environment.
The JAVA_HOME environment variable is technically not need to run javac, but I recommend setting it because it makes changes to the Java environment easier.
* Confirm your JDK folder in File Explorer or any other way. Let's say it's C:\Program Files\Java\jdk1.8.0_91.
* Set your JAVA_HOME variable to that path, for instance set JAVA_HOME="C:\Program Files\Java\jdk1.8.0_91" * Add the Java bin folder to the PATH variable, usually at the end. For instance, if PATH ends with C:\some\path, edit PATH so that it ends C:\some\path;%JAVA_HOME%\bin * If you have a command line window open, close it and open it again so that the environment variables will take effect.
All things are lawful, but not all things are profitable.
Knute Snortum wrote:
* If you have a command line window open, close it and open it again so that the environment variables will take effect.
This is a common one to forget to do (and I am by no means immune to that).
It often results in cries of "but I changed it!", usually followed by "Doh!"...
It is. But my way has two advantages: 1) there are programs that need JAVA_HOME and this way you remember to set it, and 2) you don't have to go searching through a possibly large PATH to find the Java version.
All things are lawful, but not all things are profitable.