ADC Home > Reference Library > Technical Q&As > Legacy Documents > Java >

Legacy Documentclose button

Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.

Current information on this Reference Library topic can be found here:

What is JAR caching?


Q: What is JAR caching?

A: Java code is frequently stored on servers in a special type of file called a JAR (for Java Archive). If a Java applet uses many JARs, or if the JARs are very large, it can take considerable time for the browser to load these files. MRJ 2.2.3 greatly improves JAR caching.

Previous versions of MRJ had caching, but it was up to the browser, and the cache was shared with HTML files. MRJ JAR caching saves copies of these files on your local hard drive. When you use a JAR again, MRJ checks to see if there is a newer version on the server by sending a HTTP GET for the JAR file with an if-modified-since modifier, using the last modified date it previously got from the server. If the response from the server is HTTP_NOT_MODIFIED, the cached JAR is used and the applet runs immediately. If the response from the server is a variation of HTTP_OK, MRJ looks at the last modified field, and if it is not the cached value, the JAR is re-fetched.

MRJ cached JAR files are saved by default in a folder named "MRJ Cache" located in the System Preferences folder. Over time, this folder may grow in size, but by default, storage space will not exceed 100MB. If you want to reclaim some of this space, you can quit all running applications that use Java and then drag the "MRJ Cache" folder to the trash. The next time MRJ needs to cache a JAR file, it will create a new "MRJ Cache" folder.

Q: How do I change the default settings for JAR caching?

A: It is possible to change the default settings by modifying properties in the "mrj.properties" file. These properties can be set by adding a file called "mrj.properties" to the "lib" folder within the "MRJLibraries" folder (in the System Folder:Extensions folder). This file does not exist by default - it can be created and edited with any text editor.

Setting the property com.apple.mrj.cache.size to 50M represents a JAR cache size of 50MB. You may set this value larger or smaller as needed. To disable JAR caching, set the property com.apple.mrj.useJarCaching to false. If a cache directory is specified with the property com.apple.mrj.cache.directory, the directory must exist or JAR caching will be disabled. The JAR cache options are sensitive to trailing spaces and MRJ provides no error checking on property values.

The default values are in bold:

com.apple.mrj.cache.size 100M
com.apple.mrj.useJarCaching true/false Enable/disable caching.
com.apple.mrj.cache.verbose true/false Log caching information to the Java console.

com.apple.mrj.cache.verbose.miss true/false Log cache misses to the Java console
com.apple.mrj.cache.verbose.hit true/false Log cache hits to the Java console
com.apple.mrj.cache.logfile <path to log file> Log information to file instead of console.
com.apple.mrj.cache.directory <path to existing folder> Specify the location of the JAR cache folder.

 Listing 1. An example mrj.properties file that sets the JAR caching to 200MB, the cache folder on the desk top of a volume named "HD" in a folder called "JCache", and logs cache information to a file name "JLogFile" at the root of a volume named "HD".

com.apple.mrj.cache.size=200M
com.apple.mrj.cache.directory=/HD/Desktop Folder/JCache
com.apple.mrj.cache.verbose=true
com.apple.mrj.cache.logfile=/HD/JLogFile

[Oct 06 2000]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.