A new classpath set up under System properties > environment variables> system variables as
C:\java\1.4.2_10\lib\tools.jar
3.Trying to compile programs in MS-Dos
> I assume this converts it to a class file. c:\java\projects>javac Welcome1.java > but I keep getting �java\projects� is not recognizes as an internal or external command, operable program or batch file
4.In MS-Dos when I type c:\ javac Welcome1.java
States error : error cannot read : Welcome1.java
5.when I type just c:\java I get an usage output of Usage: java [-options] class [args�] <to execute a class> or java java [-options] �jar jarfile [args�] <to execute a jar file>
6.when I type c:\javac I get usage output of Usage: javac <options> <source files> Etc
>I would like to know if my classpath is correct. What should I type in MS-Dos to compile the program?
Originally posted by Rim Cha: I assume this converts it to a class file. c:\java\projects>javac Welcome1.java but I keep getting �java\projects� is not recognizes as an internal or external command, operable program or batch file
Is 'c:\java\projects>' the DOS prompt or are you actually typing that ? The error message suggests the latter which is wrong. All you need to type is
javac Welcome1.java
Joanne
Rim Cha
Greenhorn
Joined: Aug 17, 2006
Posts: 2
posted
0
Hi when I type
javac Welcome1.java
I get
error: cannot read: Welcome1.java 1 error
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
9
posted
0
try
javac -classpath . Welcome1.java
The classpath option tells javac where to look for files. '.' is the current directory.
tools.jar normally does not need to be in classpath, unless you program is using programatic interface of some jdk tools. But it should not be a problem when it is in classpath.
Firts you need to know where is Welcome1.java located. If it is in C:\java\projects then the commands are
If class Welcome1 uses other classes, you may get compiler errors without specifiyng classpath. [ August 18, 2006: Message edited by: Vlado Zajac ]
You should not put tools.jar in the CLASSPATH. In fact, you should not set the CLASSPATH environment variable at all. If it is not set, Java by default looks in the current directory for class files to run.
You should add the bin directory of the JDK to the PATH environment variable. The installation notes explain how to do that for different versions of Windows (see step 5 of the instructions).
After you did that, follow this tutorial to the letter to compile and run your first Java program: Hello World Tutorial
(Note, the tutorial says you need JDK 6, but it works exactly the same with JDK 5 and other older versions).