The class is the unit used to build all applications in the Java programming language. Different classes, or sets of classes, are generally stored on separate computer files. That allows for more modular program structures -- with the consequent benefits of maintainability and reusability -- and for the use of class libraries across many applications. A Java program can use classes defined in other files by "importing" them into its context.
Identify the name of the package that contains the Java class(es) you need. Java packages are similar to libraries in other programming languages. A good resource for finding which package contains a given class in the standard Java Platform is Oracle's "API Specification" Web document (see Resources).
Import one class at a time by including a fully-specified "import" statement at the beginning of your Java program. For example, "import java.net.InetAddress;" imports only the InetAddress class.
Import a family of related classes by including a single wildcard "import" statement at the beginning of your code. For example, "import java.net.*;" imports all classes that share the "java.net" prefix, such as InetAddress, Proxy and URL.