Some Differences Between ZIP and JAR FormatsThe JAR file format was really introduced in the JDK 1.1 version. Although there was little to do with JAR files in 1.0.2, it wasn't until the JDK 1.1 when JAR files started to become the preferred method of packing classes. Most of the literature that was produced a few years ago had to do with how JAR files could be used in Applets. This was mainly due to the increased download speed because of the manner in which HTTP downloads files. However, now entire applications are being distributed in JAR file formats as described in the "Using JAR Files" section previously. Although the JAR file format is based on the ZIP file format, there are some differences between ZIP files and JAR files when it comes to using one or the other in Java applications. Although in earlier versions of Java, ZIP files were used for things such as packing the Java libraries in the classes.zip file, JAR files are used almost exclusively in most applications today. You'll notice that Sun distributes the Java libraries now as JAR files. Look in the lib directory under your Java installation directory. You should see an rt.jar file under the JAVA_HOME/jre/lib and probably the tools.jar file in the JAVA_HOME/lib directory. That's not to say that you won't come across the occasional third-party Java tool that uses ZIP files. This is okay, because there is still support in the core Java APIs for the ZIP file format. The real differences revolve around security and the manifest file. Use JAR files for packaging your applications to take advantage of the benefits mentioned previously. When to Use JAR sYou should consider using a JAR archive for your applications if any of the following apply:
|