ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaha_5.4.0.1/classpth.htm

127 lines
8.9 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="concept" />
<meta name="DC.Title" content="Java classpath" />
<meta name="abstract" content="The Java(TM) virtual machine uses the Java classpath to find classes during runtime. Java commands and tools also use the classpath to locate classes. The default system classpath, the CLASSPATH environment variable, and the classpath command parameter all determine what directories are searched when looking for a particular class." />
<meta name="description" content="The Java(TM) virtual machine uses the Java classpath to find classes during runtime. Java commands and tools also use the classpath to locate classes. The default system classpath, the CLASSPATH environment variable, and the classpath command parameter all determine what directories are searched when looking for a particular class." />
<meta name="DC.Relation" scheme="URI" content="config.htm" />
<meta name="DC.Relation" scheme="URI" content="sysprop.htm" />
<meta name="DC.Relation" scheme="URI" content="international.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="classpth" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Java classpath</title>
</head>
<body id="classpth"><a name="classpth"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Java classpath</h1>
<div><p>The Java<sup>(TM)</sup> virtual machine uses the Java™ classpath
to find classes during runtime. Java commands and tools also use the classpath
to locate classes. The default system classpath, the CLASSPATH environment
variable, and the classpath command parameter all determine what directories
are searched when looking for a particular class.</p>
<p>In the Java 2 Software Development Kit (J2SDK), Standard Edition,
the java.ext.dirs property determines the classpath for the extensions that
are loaded. See <a href="instextn.htm">Install extensions for the IBM<sup>®</sup> Developer
Kit for Java</a> for more information.</p>
<p>The default bootstrap classpath is system-defined, and you should not change
it. On your server, the default bootstrap classpath specifies where to find
the classes that are part of the IBM Developer Kit, the Native Abstract Window
Toolkit (NAWT), and other system classes.</p>
<p>To find any other classes on the system, you must specify the classpath
to search by using the CLASSPATH environment variable or the classpath parameter.
The classpath parameter that is used on a tool or command overrides the value
that is specified in the CLASSPATH environment variable.</p>
<p>You can work with the CLASSPATH environment variable using the Work with
Environment Variable (WRKENVVAR) command. From the WRKENVVAR display, you
can add or change the CLASSPATH environment variable. The Add Environment
Variable (ADDENVVAR) command and Change Environment Variable (CHGENVVAR) command
either add or change the CLASSPATH environment variable.</p>
<p>The value of the CLASSPATH environment variable is a list of path names,
separated by colons (:), which are searched to find a particular class. A
path name is a sequence of zero or more directory names. These directory names
are followed by the name of the directory, the ZIP file, or the JAR file that
is to be searched in the integrated file system. The components of the path
name are separated by the slash (/) character. Use a period (.) to indicate
the current working directory.</p>
<p>You can set the CLASSPATH variable in the Qshell environment by using the
export utility that is available using the Qshell Interpreter.</p>
<p>These commands add the CLASSPATH variable to your Qshell environment and
set it to the value <samp class="codeph">" .:/myclasses.zip:/Product/classes."</samp></p>
<ul><li>This command sets the CLASSPATH variable in the Qshell environment: <blockquote><pre>export -s CLASSPATH=.:/myclasses.zip:/Product/classes</pre>
</blockquote>
</li>
<li>This command sets the CLASSPATH variable from the command line: <blockquote><pre>ADDENVVAR ENVVAR(CLASSPATH) VALUE(".:/myclasses.zip:/Product/classes")</pre>
</blockquote>
</li>
</ul>
<p>The J2SDK searches the bootstrap classpath first, then the extension directories,
then the classpath. The search order for J2SDK, using the previous example
above, is:</p>
<ol><li>The bootstrap classpath, which is in the sun.boot.class.path property,</li>
<li>The extension directories, which is in the java.ext.dirs property,</li>
<li>The current working directory,</li>
<li>The myclasses.zip file that is located in the "root" (/) file system,</li>
<li>The classes directory in the Product directory in the "root" (/) file
system.</li>
</ol>
<p>When entering the Qshell environment, the CLASSPATH variable is set to
the environment variable. The classpath parameter specifies a list of path
names. It has the same syntax as the CLASSPATH environment variable. A classpath
parameter is available on these tools and commands:</p>
<ul><li><samp class="codeph">java</samp> command in Qshell</li>
<li><samp class="codeph">javac</samp> tool</li>
<li><samp class="codeph">javah</samp> tool</li>
<li><samp class="codeph">javap</samp> tool</li>
<li><samp class="codeph">javadoc</samp> tool</li>
<li><samp class="codeph">rmic</samp> tool</li>
<li>Run Java (RUNJVA) command</li>
</ul>
<p>For more information about these commands, see <a href="comtools.htm">Commands
and tools for the IBM Developer Kit for Java</a>. If you use the classpath parameter
with any of these command or tools, it ignores the CLASSPATH environment variable.</p>
<p>You can override the CLASSPATH environment variable by using the java.class.path
property. You can change the java.class.path property, as well as other properties,
by using the SystemDefault.properties file. The values in the SystemDefault.properties
files override the CLASSPATH environment variable. For information on the
SystemDefault.properties file, see the <a href="sdpropf.htm">SystemDefault.properties
file</a>.</p>
<p> In J2SDK, the -Xbootclasspath option also affects what directories the
system searches when looking for classes. Using -Xbootclasspath/a:<em>path</em> appends <em>path</em> to
the default bootstrap classpath, /p:<em>path</em> prepends <em>path</em> to the
bootstrap classpath, and :<em>path</em> replaces the bootstrap classpath with <em>path</em>.</p>
<div class="note"><span class="notetitle">Note:</span> Be careful when you specify -Xbootclasspath because unpredictable results
occur when a system class cannot be found or is incorrectly replaced by a
user-defined class. Therefore, you should allow the system default classpath
to be searched before any user-specified classpath.</div>
<p>See <a href="sysprop.htm">Java system properties</a> for information
about how to determine the environment in which Java programs run.</p>
<p>For more information, see the <a href="../apis/pgm1.htm" target="_blank">Program and CL Command APIs</a> or the <a href="../ifs/rzaaxkickoff.htm" target="_blank">Integrated
file system</a>.</p>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="config.htm" title="After you install the IBM Developer Kit for Java on your iSeries server, you can customize your server.">Customize your iSeries server for the IBM Developer Kit for Java</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="sysprop.htm" title="Java system properties determine the environment in which you run your Java programs. They are similar to system values or environment variables in i5/OS.">Java system properties</a></div>
<div><a href="international.htm" title="You can customize your Java programs for a specific region of the world by creating internationalized Java program. By using time zones, locales, and character encoding, you can ensure that your Java program reflects the correct time, place, and language.">Internationalization</a></div>
</div>
</div>
</body>
</html>