Computer does not recognise javac?

Hi

I'm from UK, although I've used one for ages I am new to computing itself and very new to programming - in fact I haven't started yet because I cannot get my JDK to work!! I have downloaded it successfully, it is installed and I have verified the version from athe command prompt. I have written a programme as detailed in my Programming with Java book, and saved it with a java file extension and I am sure it is correct. But when I try to compile mit I get "'javac' is not recognised as an internal or external command, operable program or batch file"

My book has no further advice on what to do - can anyone on this site offer me any help please.

Thanks

[689 byte] By [mzungua] at [2007-10-2 7:03:12]
# 1
Have you tried running through the steps at http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html
Caffeine0001a at 2007-7-16 20:33:36 > top of Java-index,Developer Tools,Java Compiler...
# 2
The above recommendation is the way to go. Click First Steps and then be sure to consult the Installation Instructions, Step #5, from this link in the document:Consult the installation instructions.
ChuckBinga at 2007-7-16 20:33:36 > top of Java-index,Developer Tools,Java Compiler...
# 3

Hi guys

I really appreciate the replies. I have now run through all the instructions on the link and in my book again. However I am unable to sett up my computer to successfully compile anything, unless I copy the file to be compiled into the same folder containing javac.exe! No mattter what I type in elsewhere, or how I type in a variable/classpath I always get " 'javac' is not recognised as an internal or external command...."etc

I am sure I have typed it all in correctly

Any ideas please?

Thanks

mzungua at 2007-7-16 20:33:36 > top of Java-index,Developer Tools,Java Compiler...
# 4

There is something wrong with your path:

Did you follow the instructions from that link that said:

Note: If you choose this option, each time you compile or run a program, you'll have to precede your javac and java commands with C:\jdk5.0\bin\. To avoid this extra typing, consult the section [url http://java.sun.com/j2se/1.5.0/install-windows.html#Environment]Update the PATH variable[/url] in the installation instructions

And did you go to http://java.sun.com/j2se/1.5.0/install-windows.html#Environment and follow the instructions there?

If you did so and your getting the same error, please start a command prompt.

To start a command prompt:

Click on Start->Run.... Then next to "Open:", type cmd

In the Window C:\WINDOWS\system\cmd.exe type path and hit Return. This will show your path. Copy your path and post it here.

Also post the path to your javac.exe. It should be something like: c:\jdk1.5.0_06\bin

Hint: You should see your path to javac.exe in the path above.

Caffeine0001a at 2007-7-16 20:33:36 > top of Java-index,Developer Tools,Java Compiler...
# 5

Hi

I have opened the command prompt as you suggested (this takes me into C:\Documents and Settings\Nick ) but unable to complete that suggestion because i am not too sure what you mean by"In the Window C:\WINDOWS\system\cmd.exe type path and hit Return." HoweverI have gone into C:\windows\system and typed path,, it comes up with PATH=C:\WINDOWS\System32. There is no cmd.exe in that directory, I have looked but anyway I have typed out C:\WINDOWS\system\cmd.exe path but all that comes up is the information about the Windows version I am using.

I have at last managed to compile my first programme by copying that source file into the same folder as the javac.exe file and compiling it from the command prompt in the same directory. I also ran the programme successfully from there. However, with the same source file in any other directory, then no matter what I type into the path/variable, I cannot achieve any thing other than seeing " 'javac' is not recognized as an internal or external...." etc . My Programming book suggests the directory with the tools.jar file but I have also typed in the path to the directory with the javac.exe file in too. So I have used these paths:-

C:\Program Files\Java\jdk1.5.0_04\bin\javac.exe

C:\Program Files\Java\jdk1.5.0_04\lib\tools.jar

Also C:\Program Files\Java\jdk1.5.0_04\bin and any other suitable looking configuration I can find. I don't know if this gives you any clues as to what my problem is. Its good of you to help.

Thanks again

mzungua at 2007-7-16 20:33:36 > top of Java-index,Developer Tools,Java Compiler...
# 6

Do you get 'javac' is not recognized as an internal or external... when you type the following at the command prompt?:

"C:\Program Files\Java\jdk1.5.0_04\bin\javac.exe"

The quotes are required because of the space in "Program Files"

Then to compile a java file like Hello.java you need to type

"C:\Program Files\Java\jdk1.5.0_04\bin\javac.exe" Hello.java

to compile Hello.java in the current directory.

Once again don't forget the quotes("").

If you don't want to type out "C:\Program Files\Java\jdk1.5.0_04\bin\javac.exe" ever time you want to use javac you need to add

C:\Program Files\Java\jdk1.5.0_04\bin\ to your path. The instructions at http://java.sun.com/j2se/1.5.0/install-windows.html#Environment I previous gave you will tell you how. Once you follow those instructions, the next commant prompt you open up and type path will show:

PATH=C:\WINDOWS\System32;C:\Program Files\Java\jdk1.5.0_04\bin\

And all you then have to type is javac at the command prompt.

This was all explained earlier in links I gave you. (http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html)

Caffeine0001a at 2007-7-16 20:33:36 > top of Java-index,Developer Tools,Java Compiler...
# 7
http://forum.java.sun.com/thread.jspa?threadID=687858&tstart=0Pradhip
Pradhipa at 2007-7-16 20:33:36 > top of Java-index,Developer Tools,Java Compiler...
# 8

Hi Caffeine0001

Ok, look I am beginning to feel stupid now, however I can assure you that I have followed all instructions to the letter, then jumbled the dam letters up any old how and followed them too.

I am able to compile source files by typing out "C:\Program Files\Java\jdk1.5.0_04\bin\javac.exe" from the directory that the source file is in. However I do not want to type that out all the time so again I have followed all the instructions from the links you gave me. These instructions are as the instructions in the Programming with Java book that I have.

I have tried EVERYTHING in the Environment Variables Classpath but I am unable to compile unless I type out "C:\Program Files\Java\jdk1.5.0_04\bin\javac.exe"

I have typed in "C:\Program Files\Java\jdk1.5.0_04\bin\javac.exe"

C:\PATH\Systems32;"C:\Program Files\Java\jdk1.5.0_04\bin\javac.exe"

C:"\Program Files\Java\jdk1.5.0_04\bin\javac.exe"

In fact every type of variation that I can think of that matches your advice, advice in the book, advice in the links - and then varied it with every type of variation I can come up with. But unless I am in the directory with the source file and type that "C:\Program Files\Java\jdk1.5.0_04\bin\javac.exe" out in full then it will not compile, I just get 'javac' is not recognized as an internal or external...

I cannot see what I am not doing that everything tells me to do

mzungua at 2007-7-16 20:33:36 > top of Java-index,Developer Tools,Java Compiler...
# 9
Well I've given up except for two more suggestions.1. Try it on another computer.2. Find a local computer geek and have him/her help you.
Caffeine0001a at 2007-7-16 20:33:36 > top of Java-index,Developer Tools,Java Compiler...
# 10

Ok, I'll give it a try.

You're using Windows NT or 2000 or XP, right?

Your Java version is 1.5.0_04, right?

The Java Development Kit (JDK) is installed in C:\Program Files\Java\jdk1.5.0_04, right?

OK, then, follow these instructions to set the PATH in Windows.

Choose Start, Settings, Control Panel, and double-click System. On NT, select the Environment tab; on 2000 and XP select the Advanced tab and then Environment Variables.

Look for "Path" in the User Variables and System Variables. If you're the only computer user, the best place to update is the System Variables. If there are multiple computer users and the "Path" is in both places, choose where you want to change - System Variables will affect all users.

Add this value (notice the leading semi-colon)

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

immediately following the existing entry without any intervening spaces.

Capitalization doesn't matter.

Click "Set", "OK" or "Apply".

The PATH is a series of directories separated by semi-colons (;). Windows looks for programs in the PATH directories in order, from left to right. You should only have one bin directory for a JDK in the path at a time (those following the first are ignored), so if one is already present, you can update it to C:\Program Files\Java\jdk1.5.0_04\bin.

The new path takes effect in each new Command Prompt window you open after setting the PATH variable.

Open a new Command Prompt window (Start - Run - "cmd") and type echo %path% which will print the PATH variable contents. Verify that your addition is there.

If so, type javac - version at the prompt, it will tell you the version and a few other things.

ChuckBinga at 2007-7-16 20:33:36 > top of Java-index,Developer Tools,Java Compiler...
# 11

Hi guys and I want to thank you for alloyour help.

First of all, I have done it!! I can compile from any directory just by typing javac Source file. I did this following all yr advice but by sticking the path value into User Variables instead of System Variables. I am the only user of the computer though. This value is also in System Values but it doesn't make any difference - the identical value has been in there since the beginning.

Thanks again, hope you have a Merry Christmas and a Happy New Year

mzungua at 2007-7-16 20:33:36 > top of Java-index,Developer Tools,Java Compiler...