CLASSPATH

P

printf

I tried to set the CLASSPATH environment variable today, but
command.com told me it doesn't exist! Do I have to be in a certain
directory to access this CLASSPATH variable? What's the difference
between PATH and CLASSPATH anyway? Sorry, I'm a n00b to java....
 
J

John B. Matthews

printf said:
I tried to set the CLASSPATH environment variable today, but
command.com told me it doesn't exist! Do I have to be in a certain
directory to access this CLASSPATH variable? What's the difference
between PATH and CLASSPATH anyway? Sorry, I'm a n00b to java....

Setting the CLASSPATH system variable is OS dependent:

<http://java.sun.com/docs/books/tutorial/java/package/managingfiles.html>

Specifying the class path explicitly using command line options has some
advantages.
 
A

Arved Sandstrom

printf said:
I tried to set the CLASSPATH environment variable today, but
command.com told me it doesn't exist! Do I have to be in a certain
directory to access this CLASSPATH variable? What's the difference
between PATH and CLASSPATH anyway? Sorry, I'm a n00b to java....

How were you trying to set it?

Myself, I can't think of a situation where trying to set an environment
variable tells you it doesn't exist. After all, in Windows, Linux/UNIX, Mac
OS X, the mere act of setting a non-existent environment variable makes it
exist.

AHS
 
P

printf

How were you trying to set it?

Myself, I can't think of a situation where trying to set an environment
variable tells you it doesn't exist. After all, in Windows, Linux/UNIX, Mac
OS X, the mere act of setting a non-existent environment variable makes it
exist.

AHS

Well I haven't actually tried to set the variable yet, but when I type
in CLASSPATH at the command line,
the system tells me that it doesn't exist. I know for a fact that
somewhere the CLASSPATH exists because
I'm using classes from the Java Platform API in my programs. I set
the PATH variable to include the JDK yesterday,
and apparently my programs are now able to import classes from the
API. Haven't gotten any compiler errors.
Are the PATH and CLASSPATH variables the same thing? I'm wondering if
maybe I don't need to set the CLASSPATH
variable since I've already set PATH.
 
P

printf

Setting the CLASSPATH system variable is OS dependent:

<http://java.sun.com/docs/books/tutorial/java/package/managingfiles.html>

Specifying the class path explicitly using command line options has some
advantages.

Thank you for the link! I typed 'set CLASSPATH' into the command
prompt, but I got the following response:
"Evironment variable CLASSPATH is not defined."

This confused me because all my programs are working correctly, and
they all use imported classes from other packages.
It appears that the CLASSPATH is set correctly, but I can't view it at
the command prompt (in Windows).
 
P

printf

That's not from a CLASSPATH environment variable.  That's from the boot
classpath.  So you don't "know for a fact that somewhere the CLASSPATH exists"
because most likely it does not, as such.

If no CLASSPATH variable is set, and no classpath specified at run time, Java
tools (such as 'java') pretend that one was set comprising ".".  Most tools
recognize the option "-classpath", equivalently "-cp", to specify a specific
classpath, usually a much wiser option than using the CLASSPATH environment
variable.

This is all documented on the Java web site.

As to displaying the value of CLASSPATH environment variable if it exists,
that is OS knowledge, not Java knowledge.  From a Windows command line try
"echo %CLASSPATH%", or from its GUI navigate to the "System" dialog of the
Control Panel and click on the "Environment" button.

I guess you'll have to google around for references on Windows environment
variables and command-line access thereto.

Thanks, Lew, I appreciate your help! I suppose it was a little
presumptuous of me
to say I knew for a fact that CLASSPATH was already set. LOL

I set the CLASSPATH through the control panel (classic view) just now
because every
time I tried to set it through a session of command.com, each new
session had
CLASSPATH undefined.

Everything appears to be in working order now! Sorry I'm such a
n00b ;-)
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top