| TWiki . Javapedia . ClassPath |
java launcher command from the J2SDK? takes a -classpath option.
The term is used more loosely to refer to the locations where classes are searched for in other kinds of applications, such as applets or web applications. Typically the classes are packaged in JARs. When compiling Java source code, the class path typically specifies the root directory containing the directory of the top level package. For example, if you have a class called Foo in the package com.acme, the "com" portion would be mapped to the "com" directory and "acme" to the "acme" subdirectory under "com". If you put the "com" directory into a directory called /home/john/projects (Unix), then you would set the classpath to /home/john/projects in order for the Java compiler (javac) to find your source files. For Windows systems, if you put the "com" directory into c:\projects then you would set the classpath to c:\projects.
It is also recommended to find (read-only) resources, such as images or XML data, in the class path, just like bytecode class files. The method Class.getResource (and some related methods) are appropriate for finding such resources. When you access resources this way, your application does not need to refer to absolute file names (or rely on the process' current working directory), and can be more easily packaged for deployment in an applet, web application, executable JAR file, JavaWebStart package, etc.
If you create your own class loaders, you can load classes from anywhere you like, so the meaning of class path is less precise in this case.
See Classloaders for information about class loaders.
Did you mean to look at the GnuClassPath page?
Also See
----- Revision r10 - 14 Jan 2009 - 03:24:13 - Main.yawmark
|