|
Packaging in Java
An Introduction |
|
Prof. David Bernstein |
| Computer Science Department |
| bernstdh@jmu.edu |
plant.Leaf and
hierarchy.Leaf) to create a
unique, fully-qualified namejava.awt appears to contain
java.awt.event) but it doesn'tedu.jmu.cs.package
)com._static.package
)
java.lang:
java.lang
(e.g., the String class)java.util.ArrayList)import statements to tell the compiler/interpreter
how to try and resolve unidentified symbols and then
use the unqualified name of the classjava.awt.List
and java.util.List in the same classstatistics.parametric is in the directory
parametric inside of the
directory statistics
CLASSPATH)
or with a compiler/interpreter switch (i.e., -cp or
-classpath)package Statement in each Class:
static Members:
static Members from Imported Packages:
import static you can access static
members without including the package name or the
class name (e.g., abs()
rather than Math.abs())| Block | Entity is accessible within a block of code |
| Subprogram | Entity is accessible within a subprogram |
| Class/Private | Entity is accessible by all entities within a class |
| Generalized/Protected | Entity is accessible in its class and all extensions |
| Complete/Public | Entity is accessible everywhere |
| Group | Entity is accessible to all members of a
pre-defined group (e.g., package visibility in
Java, COMMON blocks in FORTRAN) |
~
.jar Files)jar toolCLASSPATH
java or
javaw).class files in a .jar file
(e.g., images, configuration files, input files)File objects normally refer to
files in the file system.jar file
you should use a URI objectURI is a multi-step
process that uses the getResource()
method in the Class classmanifest.mf):
Manifest-Version: 1.2
Main-Class: Driver
Note: The class containing the main(String[])
method needn't be named Driver.
application.jar):
jar cvfm application.jar manifest.mf *.class