Java package: Difference between revisions

Content deleted Content added
Bergstrom Kids
Tag: references removed
m Reverted edits by 2601:742:8000:D240:D483:E181:EC23:5D4A (talk): using Wikipedia for advertising/promotion (HG) (3.4.9)
Line 49:
compresses all .class files into the JAR file ''myPackage.jar''. The 'c' option on the command line tells the jar command to "create new archive." The ' f ' option tells it to create a file. The file's name comes next before the contents of the JAR file.
 
==Package naming conventions==
Packages are usually defined using a [[hierarchical]] naming [[pattern]], with some levels in the hierarchy separated by periods (<code>.</code>, pronounced "dot"). Although packages lower in the naming hierarchy are often referred to as "subpackages" of the corresponding packages higher in the hierarchy, there is almost no semantic relationship between packages. The Java Language Specification establishes package naming conventions to avoid the possibility of two published packages having the same name. The naming conventions describe how to create unique package names, so that packages that are widely distributed will have unique namespaces. This allows packages to be separately, easily and automatically installed and catalogued.
 
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>[http://www.oracle.com/technetwork/java/codeconventions-135099.html Code Conventions for the Java Programming Language: 9. Naming Conventions]</ref>
Check out Bergstrom Kids Youtube
 
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>http://docs.oracle.com/javase/specs/jls/se6/html/packages.html#7.7</ref>
 
==Core packages in Java SE 8==