A Java package is a set of classes which are grouped together.
This grouping helps to organize Java classes and codevent multiple Java classes with the same name.
Using Java Packages
To use a package in your Java source code, you must either import the package or use the fully qualified class name each time you use a class.
Using Fully Qualified Class Names
This example uses the Ammunition class from the ballistics package:
ballistics.Ammunition caliber = new ballistics.Ammunition();
As you can imagine, using fully qualified class names can become a bit of a hassle.
import java.util.ArrayList; // Import the ArrayList class from the java.util package import java.util.*; // Import all public classes from the java.util package
Optional Packages are packages of Java classes which are used to extend the core Java platform.
Java classes stored within Optional Packages can be used by the JVM without the need to be explicitly included in the CLASSPATH.
Optional Packages are usually stored in JAR files.
In earlier versions of Java, Optional Packages were known as Standard Extensions.
Installed Optional Packages
JAR files containing Installed Optional Packages are copied into the lib/ext subdirectory.
Download Optional Packages
Download Optional Packages are optional packages which are loaded from outside the JRE/JVM file structure via a Class-Path header in a Manifest file.
For more information on Optional Packages, read the Optional Package Overview.