• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems compiling program-can anyone help??

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

 
Rim Cha
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
when I type

javac Welcome1.java

I get

error: cannot read: Welcome1.java
1 error
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try

javac -classpath . Welcome1.java

The classpath option tells javac where to look for files. '.' is the current directory.
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic