Content deleted Content added
No edit summary Tags: nowiki added Visual edit Mobile edit Mobile web edit |
No edit summary |
||
Line 8:
==Using packages==
In a Java source file, the package that this file's class or classes belong to is specified with the <code>package</code
<source lang="java">
package java.awt.event;
</source>
To use a package's classes inside a Java source file, it is convenient to import the classes from the package with an <code>import</code> declaration. The following declaration
<source lang="java">
import
</source>
imports all classes from the <code>java.awt.event</code> package, while the next declaration
Line 47:
jar cf myPackage.jar *.class
compresses all .class
==Package naming conventions==
Packages are usually defined using a [[hierarchical
In general, a package name begins with the top level ___domain name of the organization and then the organization's ___domain and then any subdomains, listed in reverse order. The organization can then choose a specific name for its package. Subsequent components of the package name vary according to an organization's own internal naming conventions.<ref
For example, if an organization in Canada called MySoft creates a package to deal with fractions, naming the package <tt>ca.mysoft.fractions</tt> distinguishes the fractions package from another similar package created by another company. If a German company named MySoft also creates a fractions package, but names it <tt>de.mysoft.fractions</tt>, then the classes in these two packages are defined in a unique and separate namespace.
Complete conventions for disambiguating package names and rules for naming packages when the Internet ___domain name cannot be directly used as a package name are described in section 7.7 of the Java Language Specification.<ref>
==Core packages in Java SE 8==
|