CMD not recognizing javac.exe

0

On my Windows 7 64 bits, I changed the JAVA_HOME variable to point on 64 bits JRE, and changed it again to point on 64 bits JDK. I did same operation a few times.

Every time I do this change I close and open the cmd again .

Screen capture of my env variables

Note that same settings were working before.

Any idea of what's happening ?

Mehdi

Posted 2016-04-17T19:02:55.930

Reputation: 59

Answers

0

Any idea of what's happening?

JAVA_HOME should point to the root directory of your Java installation:

setx JAVA_HOME C:\Program Files\Java\jdk1.7.0_79

You also need to add the Java bin directory to your path:

setx PATH C:\Program Files\Java\jdk1.7.0_79\bin;%PATH%

See Installing the JDK Software and Setting JAVA_HOME and PATH and CLASSPATH for more information.

DavidPostill

Posted 2016-04-17T19:02:55.930

Reputation: 118 938

I defined both as system variables and not user variables. and did what you mention. It works now. thanks – Mehdi – 2016-04-17T19:24:38.807

0

I'm surprised that it worked before - had you cd'd into %JAVA_HOME%?

If you want the programs in the bin folder to be accessible from anywhere in a command prompt, you need to add it to your PATH. Since you don't have a user-specific PATH variable yet, create one, and set its value to C:\Program Files\Java\jdk1.7.0_79\bin. Then you'll be able to enter javac on a command prompt anywhere and it will work.

Also, correct values of the JAVA_HOME variable do not end with bin. (Source.) That may affect other programs that try to use Java.

Ben N

Posted 2016-04-17T19:02:55.930

Reputation: 32 973

Please see my comment for DavidPostill answer. thanks. – Mehdi – 2016-04-17T19:23:48.177