This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
With Java-4 (jdk2sdk1.4.1.02) I was always able to create a class file using: C:\Java-CK\>javac �d C:\Java-CK HelloDate.java and I would get a file called HelloDate.class. and I would be able to run this short program.
I am trying to do the same with Java-5 (jdk1.5.0_04) and it does not work. It always gives me the following error message: -Javac is not recognized as an internal or external command, operable program or batch file.
In my C:>autoexec.bat I have a line: SET PATH=%PATH%;�C:\Program Files\Java\bin� and another line: SET CLASSPATH=�C:\Program Files\Java�
Ii did that, because �javac.exe� is under \bin. What did I do wrong?
Your help would be very much appreciated. Charles.
Are you sure that javac.exe resides in c:\Program Files\Java\bin? This would mean that you would have installed the JDK into c:\Program Files\Java. Run a search on javac.exe and check which directory(ies) javac.exe lives in.
This isn't an issue of what Java 5.0 allows or does not allow. The problem seems to be that Windows cannot find the javac.exe program. Make sure that the directory that contains javac is listed in the PATH variable. If you need help with this, please let us know.
p.s. The "-d <dir-name>" option is typically only used if you want to put the class file in a different directory. Since you are specifying the same directory as the current one, you can just type "javac HelloDate.java" which will save you several keystrokes.
[ September 11, 2005: Message edited by: Layne Lund ] [ September 11, 2005: Message edited by: Layne Lund ]
Memo to John Dell'Oso, Barry Gaunt and Layne Lund: Thank you very much for your valuable help. You showed me the way to find out what was wrong with my Java program; I only had C:\Program Files\Java\bin instead of C:\Program Files\Java\jdk1.5.0.04\bin. So I made an instruction shteet how to download jdk1.5.0_04 and followed it religiously. And now, my Java program works like a charm! Here it is:
Foolproof Downloading of Java Program JDK-1_5_0_04 � NB-4_1.win.exe Into a Pentium IV Computer with Windows XP: Log on to: http://java.sun.com/J2SE/ For J2SE-5.0
1.D/L: JDK-1_5_0_04-NB-4_1.win.exe (127 MB) D/L went fine on \\AMD)
2. Install at C: Same as under 1. (and <Enter> gives: Welcome to the Install Wizard for Java 2- SED Kit, Update 4 and Netbeans IDE, 4.1.
This will install the above file on your computer; to continue: choose NEXT.
4. Installation locations will be as follows: Netbeans:C:\Program Files\netbeans-4.1 J2SDK : C:\Program Files\Java\jdk1.5.0_04 Total size: 453 MB