Placing class files inside a JAR archive

For convenience, a collection of class files can be archived into a single JAR file. A JAR file is a standard ZIP file with a different file extension, but unlike ZIP files, JAR files have strict rules regulating their content. When a JAR file is put on the ClassPath, all the classes that are placed inside the JAR file will be loaded and made available to the JVM instance.

We won't be discussing the creation of JAR archives in this chapter, but we will look at this topic in Chapter 4, Java Programming, when we build a hands-on Java language example.

A JAR file may require its own external dependencies. If this is the case, then those dependencies must also be put on the ClassPath. This is usually mentioned in the documentation of the library or tool that provides the JAR file.