aspose file tools*
The moose likes Beginning Java and the fly likes Problems compiling program-can anyone help?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problems compiling program-can anyone help??" Watch "Problems compiling program-can anyone help??" New topic
Author

Problems compiling program-can anyone help??

Rim Cha
Greenhorn

Joined: Aug 17, 2006
Posts: 2
Having problems compiling program
I am typing my program under JCreator LE which is in C:\Program Files\JCreatorV3LE\MyProjects

1.My java is in c directory

Have project folders as follows:
C:\java\projects
and
c:\java\1.4.2_10\projects

2.When I type in MS-DOS
cd c:\java

and

c:\java>dir

get

Directory of C:\java

Dates <DIR> .
Date <DIR> . .
<DIR> 1.4.2_10
0javac
<DIR> projects

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?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
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
Hi
when I type

javac Welcome1.java

I get

error: cannot read: Welcome1.java
1 error
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
try
javac -classpath . Welcome1.java
The classpath option tells javac where to look for files. '.' is the current directory.
Vlado Zajac
Ranch Hand

Joined: Aug 03, 2004
Posts: 245
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 ]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884
    
  10

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).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems compiling program-can anyone help??
 
Similar Threads
Trouble finding DOMParser...
error #300 & #302: cannot access class
javadoc problem, using ant build file
question about weblogic 6.1
Javac: File Not Found