Java Reference
In-Depth Information
since this variable applies to all Java runtimes on the system. As a result, coordi-
nating the search requirements of multiple Java applications (especially if they are
from various vendors) can be difficult.
Most development environments provide a way to assign a CLASSPATH vari-
able to a project. You will need to consult the documentation for the development
environment you are using to learn how to do this.
CODEBASE
Instead of the CLASSPATH setting, applets use the CODEBASE reference. This pa-
rameter specifies the directory that contains the initial applet, along with any sup-
porting classes it requires. This is the syntax:
<applet
CODEBASE = codebaseURL
code=HelloWorld
width=200
height=200>
</applet>
As you might suspect, CODEBASEs are defined in terms of a uniform resource
locator (URL) on the Web server. For security reasons, Java applet CODEBASE ref-
erences must be on the same Web server (that is, must have the same domain
name) as the HTML page that started the applet.
P ACKAGES
A package is a way for the Java developer to group classes that are in some way re-
lated. For example, a GeneralLedger package would likely contain an Account class
and a Ledger class. These classes might implement the business logic necessary to
manage account information or to record a transaction in the Ledger .
These classes can define package variables and methods that would be available
only to other classes in this package. In addition, public members are automatically
made available to classes in the same package. Consequently, classes in a package do
not need to import other classes in the same package.
Java defines a default package for classes that do not belong to an explicit pack-
age. You've already used the default package in your exercises. Until now, its pri-
mary benefit has been that it is a convenient mechanism to access the various
example classes. But you could use a Java package to organize the examples.
 
Search WWH ::




Custom Search