Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting class path problem

 
Raj kalaria
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you

Raj
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using jdk 1.4 please look here http://java.sun.com/j2se/1.4.2/install.html
 
paul wheaton
Trailboss
Pie
Posts: 21468
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A comma? That's new to me.

What o/s are you using?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15272
37
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic