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

87 lines
6.3 KiB
HTML
Raw 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 classes, packages, and directories" />
<meta name="abstract" content="Each Java class is part of a package. The first statement in a Java source file indicates which class is in what package. If the source file does not contain a package statement, the class is part of an unnamed default package." />
<meta name="description" content="Each Java class is part of a package. The first statement in a Java source file indicates which class is in what package. If the source file does not contain a package statement, the class is part of an unnamed default package." />
<meta name="DC.Relation" scheme="URI" content="advtopic.htm" />
<meta name="DC.Relation" scheme="URI" content="classifs.htm" />
<meta name="DC.Relation" scheme="URI" content="fileauth.htm" />
<meta name="DC.Relation" scheme="URI" content="runbatch.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="clpckdir" />
<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 classes, packages, and directories</title>
</head>
<body id="clpckdir"><a name="clpckdir"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Java classes, packages, and directories</h1>
<div><p>Each Java™ class is part of a package. The first statement
in a Java source
file indicates which class is in what package. If the source file does not
contain a package statement, the class is part of an unnamed default package.</p>
<p>The package name relates to the directory structure in which the class
resides. The integrated file system supports Java classes in a hierarchical file structure
that is similar to what you find on most PC and UNIX<sup>®</sup> systems. You must store a Java class
in a directory with a relative directory path that matches the package name
for that class. For example, consider the following Java class:</p>
<pre> package classes.geometry;
import java.awt.Dimension;
public class Shape {
Dimension metrics;
// The implementation for the Shape class would be coded here ...
}</pre>
<p>The package statement in the previous code indicates that the Shape class
is part of the classes.geometry package. For the Java runtime to find the Shape class, store
the Shape class in the relative directory structure classes/geometry.</p>
<div class="note"><span class="notetitle">Note:</span> The package name corresponds to the relative directory name in which
the class resides. The Java virtual machine class loader finds
the class by appending the relative path name to each directory that you specify
in the classpath. The Java virtual machine class loader can also
find the class by searching the ZIP files or JAR files that you specify in
the classpath.</div>
<p>For example, when you store the Shape class in the /Product/classes/geometry
directory in the "root" (/) file system, you need to specify /Product in the
classpath.</p>
<p><strong>Figure 1: Example directory structure for Java classes of the same name in different
packages</strong><br /><a name="clpckdir__rzaha505"><!-- --></a><img id="clpckdir__rzaha505" src="rzaha505.gif" alt="This&#xA;graphic shows an example directory structure for Java classes of the same&#xA;name in different packages." /><br /></p>
<div class="note"><span class="notetitle">Note:</span> Multiple versions of the Shape class can exist in the directory structure.
To use the Beta version of the Shape class, place /Beta/myclasses in the classpath
before any other directories or ZIP files that contain the Shape class.</div>
<p>The Java compiler uses the Java classpath, package name, and directory
structure to find packages and classes when compiling Java source
code. For more information, see <a href="classpth.htm">Java classpath</a>.</p>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="advtopic.htm" title="This topic provides instructions on how to run Java in a batch job and describes the Java file authorities required in the integrated file system to display, run, or debug a Java program.">Advanced topics</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="classifs.htm" title="The integrated file system stores Java-related class, source, ZIP, and JAR files in a hierarchical file structure. IBM Developer Kit for Java supports using the threadsafe file systems in the integrated file system to store and work with your Java-related class files, source files, ZIP files, and JAR files.">Files in the integrated file system</a></div>
<div><a href="fileauth.htm" title="To run or debug a Java program, the class file, JAR file, or ZIP file needs to have read authority (*R). Any directories need read and execute authorities (*RX).">Java file authorities in the integrated file system</a></div>
</div>
<div class="reltasks"><strong>Related tasks</strong><br />
<div><a href="runbatch.htm" title="Java programs run in a batch job by using the Submit Job (SBMJOB) command. In this mode, the Java Qshell Command Entry display is not available to handle the System.in, System.out, nor System.err streams.">Run Java in a batch job</a></div>
</div>
</div>
</body>
</html>