Search code examples
javajavac

setting up classpath. javac is not recognized


I am trying to run my java program from command line.

I read an article about setting up classpath, but I get an error of javac is not recognized as internal or external command. What should I do? (I dont want to set a permanent CLASSPATH) This is what I have done in my command line

D:\user> set path=%path%;C:\Program Files\Java\1.7.0_07\bin

D:\user> cd testing

D:\user\testing> javac firstProgram.java
'javac' is not recognized as an internal or external command,
operable program or batch file.

Thank you


Solution

  • Assuming that the PATH is correct1, the most likely cause is that you have a JRE installation ... and a JRE doesn't include a java compiler. You need a JDK installation if you want to compile from the command line.

    (You can confirm this by looking in the C:\Program Files\Java\1.7.0_07\bin directory to see if it contains a javac.exe file. A JRE won't ...)

    Where can I find the Java compiler to download..

    You need to download one of the JDK installers; see http://www.oracle.com/technetwork/java/javase/downloads/index.html


    1 - I don't think quotes are required in a PATH variable on Windows. At least that's what various examples that Google found for me seem to imply. But I've never really understood the logic behind quoting in Windows ...