I can't run my first program on command line\command prompt, it keeps giving me the error message below:
'javac' is not recognized as an internal or external command,operation
program or batch files
Below is what i did:
1-I installed notepad++
2-I typed my code into it and saved as C:\ex1
3-I ran my cmd and changed directory to C:\ex1
4-At C:\ex1> I typed "javac Squarer.java" (as seen in the JPG image i sent along)
5-The message i get is -'javac' is not recognized as an internal or external command,operation
program or batch files.-
NB: PLEASE I DON'T KNOW WHERE I WENT WRONG OR WHAT I HAVE TO FIX TO MAKE MY PROGRAM RUN
BECAUSE ALL THE PROGRAMS I RUN ON COMMAND LINE DISPLAY THE SAME ERROR MESSAGE.
Thanks for your HELP!
ken wise wrote:1-I installed notepad++
ken wise wrote:2-I typed my code into it and saved as C:\ex1
you must save a java file with .java extension . so in your case the file name must be "ex1.java"[example FileName.java]
ken wise wrote:3-I ran my cmd and changed directory to C:\ex1
if ex1 is the folder name, then it is fine.
ken wise wrote:4-At C:\ex1> I typed "javac Squarer.java" (as seen in the JPG image i sent along)
with this command you are asking compiler to comiple/verify your source code
ken wise wrote:5-The message i get is -'javac' is not recognized as an internal or external command,operation
but unfortunately, window cant find your compiler[javac] to execute[assume you are working on window platform] you need to add javac.exe location to the window PATH
to set this, right click on your mycomputer icon on your desktop-->advanced tab--> environment variable ---> click PATH variable in system variable and then edit/add java installation path upto bin directory example: C:\Program Files\Java\jdk1.6.0_16\bin
just mentioned fully qualified name of the javac in command prompt i.e, "C:\Program Files\Java\jdk1.6.0_16\bin\javac" Squarer.java [here path is surrounded by "" because it contains space(Program Files)]
after successful of compilation , run using "C:\Program Files\Java\jdk1.6.0_16\bin\java" Squarer
or java Squarer [if you add java location into the system path]
Please read the installation instructions for the JDK, especially step 4 (Update the PATH variable).
And please DON'T WRITE IN ALL CAPS BECAUSE IT LOOKS LIKE YOU ARE SHOUTING!!
Rite Sara wrote:You have to set classpath for this. Your class path should point to the bin folder of your jdk folder.
No, that's wrong.
You have to add the bin directory of your JDK installation to the PATH (not the CLASSPATH). The PATH is what the operating system uses to find programs to execute.
CLASSPATH is for Java itself, this is what Java uses to find Java programs (class files and JAR files) to run. Do not add the bin directory of the JDK to the CLASSPATH, that won't solve the problem.