What's the effect in different classpath set?

5

525

when setting the environment variable, one of the steps is to set the
classpath. Some books use this: classpath=c:\jdk\lib\tools.jar; c:
\jdk\lib\dt.jar; Anothers use this: c:\jdk\lib . Q: Any
different?
 
L

Lew

525 said:
when setting the environment variable, one of the steps is to set the
classpath. Some books use this: classpath=c:\jdk\lib\tools.jar; c:
\jdk\lib\dt.jar; Anothers use this: c:\jdk\lib . Q: Any
different?

Neither one works. The environment variable is 'CLASSPATH', not 'classpath',
and you don't put spaces in it.

Even after correcting those errors, the second form will not pick up the JAR
files, nor is the first form isn't necessary because the JARs in the
$JAVA_HOME/lib/ directory don't need to be part of the classpath explicitly.

In any event, all your questions should be answered by the information in the
documentation:
<http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html>

I strongly recommend that you do not use the CLASSPATH envar, but use the
-classpath (or -cp) option to your Java tools. CLASSPATH is far too global.

Also, read
<http://java.sun.com/javase/6/docs/technotes/tools/findingclasses.html>
 
M

Mark Space

525 said:
when setting the environment variable, one of the steps is to set the
classpath. Some books use this: classpath=c:\jdk\lib\tools.jar; c:
\jdk\lib\dt.jar; Anothers use this: c:\jdk\lib . Q: Any
different?

My classpath is:

CLASSPATH='.;C:\Program Files\Java\jre1.6.0_03\lib\ext\QTJava.zip'

c:\jdk in your path may refer to the path to the actual JDK. On Windows
it should be closer to something like mine.

Hey I just realized that lib\ext should be included by default, right?
So why the heck did QTJava want to add itself to the classpath in that
manner?
 
A

Arne Vajhøj

Lew said:
> nor is the first form isn't necessary because the JARs in the
$JAVA_HOME/lib/ directory don't need to be part of the classpath
explicitly.

I don't think tools.jar is in classpath by default.
I strongly recommend that you do not use the CLASSPATH envar, but use
the -classpath (or -cp) option to your Java tools. CLASSPATH is far too
global.

Very good advice.

Arne
 
5

525

Neither one works. The environment variable is 'CLASSPATH', not 'classpath',
and you don't put spaces in it.

Even after correcting those errors, the second form will not pick up the JAR
files, nor is the first form isn't necessary because the JARs in the
$JAVA_HOME/lib/ directory don't need to be part of the classpath explicitly.

In any event, all your questions should be answered by the information in the
documentation:
<http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html>

I strongly recommend that you do not use the CLASSPATH envar, but use the
-classpath (or -cp) option to your Java tools. CLASSPATH is far too global.

Also, read
<http://java.sun.com/javase/6/docs/technotes/tools/findingclasses.html>

Thanks!! Another question is: Can we ignore the CLASSPATH set if we
use the IDE (like the NetBeans) to program?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top