File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes setting class path problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "setting class path problem " Watch "setting class path problem " New topic
Author

setting class path problem

Raj kalaria
Ranch Hand

Joined: Sep 08, 2005
Posts: 72
Hi

i am installing java. and as far as my i know all machines should have a variable call CLASSPATH already defined

but in this machine which i am installing wont have that CLASSPATH variable

so i made a new entry
CLASSPATH = ,

( it will just have the above single comma)

but when i run a simple hello world program
it still gives me class not found error

can some please help
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306
Below is an example to set classpath
set CLASSPATH=.;C:\Program Files\SQLLIB\java\db2java.zip;C:\Program Files\SQLLIB\java\runtime.zip;C:\Program Files\sqllib\bin;%CLASSPATH%;.

Your classpath should point to the place where your classes are residing.
[ November 17, 2005: Message edited by: jiju ka ]
Raj kalaria
Ranch Hand

Joined: Sep 08, 2005
Posts: 72
thank you

Raj
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306
If you are using jdk 1.4 please look here http://java.sun.com/j2se/1.4.2/install.html
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20660
    ∞

A comma? That's new to me.

What o/s are you using?


permaculture Wood Burning Stoves 2.0 - 4-DVD set
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14278
    
  21

Raj,

No, every machine does not have to have a CLASSPATH variable set.

Which operating system are you using? Setting classpath to "," (comma) is almost certainly wrong.

If you do not set the CLASSPATH variable at all, Java will use the current directory as the classpath by default (which means, it will only search in the current directory for packages and class files).

Sometimes you need to have Java look in more places than just the current directory. In that case, it's best to specify the classpath on the command line when you're starting your Java program, like this (example):

java -classpath C:\oracle\ora92\jdbc\lib\ojdbc14.jar;. MyClassName

Note the ";.". This includes the current directory, which is denoted by "." (dot, not comma!).

Doing it like this is better than setting the global CLASSPATH variable, because the CLASSPATH variable influences every Java program running on your computer, and not just the program that the settings are relevant for.

For more information, see the following pages:
How Classes are Found
Setting the class path
[ November 18, 2005: Message edited by: Jesper de Jong ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting class path problem