setting javac...

Suspended
Joined
17 Mar 2004
Posts
4,934
Location
Market Drayton, Salop
lo all,

I really wanted to try the tutorials on java on the Sun website. Downloaded the latest version and installed, did the HelloWorldApp and saved it.

It then ask me to type the following into Command Prompt:

javac HelloWorldApp.java

which i did but it came up with the following:

'javac' is not recognized as an internal or external command, operable program or batch file.

Here is the tutorial link

It tells me to set the PATH variable to save me having to type it out every time. I must be stupid but i cant get it to work!!

If i try and manually enter the path i get the following:

'C:\Program' is not recognized as an internal or external command.

(java is installed in my program files folder)

Anyone any advice or suggestions??
 
because there is a space in program files, it might stop short, put the entire file path in ""

i.e. "C:\Program Files ...."
 
Right click on "My Computer"->Properties->Advanced->Environment Variables. Then in the "System variables" section, find the "Path" entry. Click Edit, go to the end of the current path, and add a semicolon followed by the path to the Java binaries, something like this:

;C:\Program Files\Java\jdk1.5.0_05\bin

Click OK, OK again, OK again and you should be done. Click Start->Run, type "cmd", press Enter, which should open a command prompt. Type "javac" and press enter. You should now get an error message from the compiler.

As for your error message: The command prompt thinks that the command you're trying to run is "C:\Program" because of the space (with the rest being considered as the parameters to pass to it.) To use paths with spaces, enclose them in double quotes, eg:

Code:
C:\>"c:\program files\java\jdk1.5.0_05\bin\javac.exe" blah.java
error: cannot read: blah.java
1 error

C:\>
 
Thanks, got it sorted now.

I swear they make it complicated on purpose, only reason i never learnt C++ was because my compiler had no manual/help file :(
 
I don't think it's a case of deliberately making it hard, it's probably more down to them assuming that the person using the software will have detailed knowledge of the platform they're developing on. Which of course, if you're only just learning, may not necessarily be true. Plus, setting environment variables changes from windows version to windows version, so they just say "set your path veriable", and leave it up to you to work out how to do it on your specific platform, it saves them having to make a different manual for each platform.

Although, all that asside it can be damn annoying sometimes. :)
 
it does actually tell you how to set the path variable for each version of windows, it just doesnt add quotes on theirs
 
I always find that it is more reliable to use the dos 7.3 forms of the directory names, windows' support fo spaces in directpry names is flaky at best.

it's usually C:\PROGRA~1 from Program Files use dir /X to see the short format names.

HT
 
Back
Top Bottom