File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "classpath" Watch "classpath" New topic


Romka Abcd

Joined: Jun 09, 2003
Posts: 1
where can i find this thing and how can i add *.jar file to it...
please give me an example, i really need it.
Richard Jensen
Ranch Hand

Joined: May 14, 2003
Posts: 67
Originally posted by Romka Abcd:
where can i find this thing and how can i add *.jar file to it...
please give me an example, i really need i

CLASSPATH is typically an environment variable that is set by a script (or batch file). How you find its current value and change it depends on the operating system. For example on Windows 2000 I can examine the value with: and on Unix I might do something like env | grep CLASSPATH.
You can also tell java to use a particular value for CLASSPATH by invoking it with -cp or -classpath. You would then supply the classpath values separated by the appropriate delimiter (';' on Windows) like so:

N 37 33 W 122 18
Charles Lyons
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
One of the simplest ways to import JAR archives into an application is to add the -classpath attribute (correct term?) on the command line when invoking the JVM for the application. For example:
java -classpath %1;%2;%3;
Where your replace %1, %2 and %3 with your jar file list, directories, or zip archives. The Java runtime will load classes from any of these location as and when required.

The other way (which is more permanent) is to set an environment variable called CLASSPATH under your operating system's architecture.
On Windows, you could do this by opening up the Environment Variables system property (Windows NT, 2000 or XP), or by using the parameter set CLASSPATH=... in the autoexec.bat file (Windows 9x).
Under Linux/Solaris, you need to refer to your particular implementation's documentation regarding the shell files (*.csh and *.sh files) and setting environment variables (env).
[ June 09, 2003: Message edited by: Charles Lyons ]

Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
I agree. Here's the link:
subject: classpath
It's not a secret anymore!