Some Differences Between ZIP and JAR Formats

   

Some Differences Between ZIP and JAR Formats

The 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 s

You should consider using a JAR archive for your applications if any of the following apply:

  • You want to decrease your applet's loading time, especially if your applet consists of many files.

  • You want to simplify the distribution of your application or make it more portable.

  • Your applet or application needs to be authenticated as trusted code.

  • You have meta-information such as version information that you want to associate with the application files.

   


Special Edition Using Java 2 Standard Edition
Special Edition Using Java 2, Standard Edition (Special Edition Using...)
ISBN: 0789724685
EAN: 2147483647
Year: 1999
Pages: 353

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net