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]
You are getting this error because it could not locate the path where java is installed on your machine.
You have to set classpath for this. Your class path should point to the bin folder of your jdk folder.