How to Use JarInfo
Please read the following steps to add the JarInfo component properly to your Java library archives:
First of all please download the current jarinfo.zip file onto your computer. This ZIP archive may be unzipped directly from Ant build scripts using the unzip task into the directories which are to be added to the target JAR archive. Of course you can extract the jarinfo.zip file manually with WinZIP or other ZIP extraction tools. The listing below shows the contents of the current jarinfo.zip file.
The jarinfo.zip file contains various files and resources in the com.lf.commons.info package. Besides the JarInfo Java classes there is the resource bundle for English and German localization (files JarInfo.properties and JarInfo_de.properties). The configuration file jarinfo.properties is expected to reside in the resource sub-directory. This file is commented out so that the default settings are used by JarInfo. You can use the included jarinfo.properties file as skeleton for your own settings.
The JarInfo component can be configured by setting variable/value pairs found in the jarinfo.properties resource file. This files is expected to reside in the com/lf/commons/info/resource/ sub-directory. The default file that comes as part of the jarinfo.zip looks as follows:
Default jarinfo.properties file
All settings are commented out (not used) so that the default values as described are used by JarInfo. You should extract a copy of the sample file as skeleton for your own settings. To activate a settings please remove the leading # character of the variable/value lines. Remember to replace the comments from the lines to the right of the = character by the values you want to set for the properties.
For some properties like JAVAINFO_LOCALE a list of values can be used (here: auto for automatic locale setting, en for English, de for German). Since properties files are based on the Java ISO-8859-1 Unicode Escapes encoding, German umlauts etc. need to be escaped using the hexadecimal Unicode sequences like \u00E4 for the ä character.
If a variable value is not properly set it will be simply ignored by JarInfo. If a setting is not being activated please check the properties file for wrong characters etc. first. Most of the shown values are self-explanatory. If you like to add own resources please store them into the com/lf/commons/info/resource/ sub-directory along with the jarinfo.properties file. The sample file shows the resource/cubes_16.png image to use as window icon. In order to make this setting work, a file named cubes_16.png needs to be copied into the resource sub-directory.
The window location values can either be set as absolute screen coordinates with (0,0) as the upper left corner or using the center value. In the latter case the JarInfo window is centered on the X or Y axis (or both) on the basis of the total screen dimensions.
Each tab can be (de)activated so that you have full control what the user/developer sees. Special components like the header label showing the file name/path, the bottom label showing the copyright info, and the Extract button are configured separately. You can set an own copyright text in order to smoothly integrate the JarInfo component into your libraries.
The Notice tab can show either plain text or formatted HTML text including images which need to be stored into the com/lf/commons/info/resource/ sub-directory again. The next code block shows a HTML fragment including an image. The resources cannot be referenced directly but must be surrounded with % characters to be replaced by JarInfo. Here, the image pattern %information_32.png% is replaced by the URL associated with resource/information_32.png in the target JAR archive. When the fragment is set as value of the JAVAINFO_NOTICE variable then it must be converted to a single-line pattern.
A sample customized HTML notice text including an image
The variables JAVAINFO_SHOW_TAB_MANIFEST and JAVAINFO_SHOW_TAB_SERVICES may be set to auto which means that these tabs are only displayed if the archive contains a manifest file or service provider declarations at all. The plain_wrapped value of the JAVAINFO_MANIFEST_MODE variable causes JarInfo to print the MANIFEST.MF file without any modifications while plain_unwrapped concatenates the lines that have been separated due to the JAR file format specification (looks better).
The entries of the JAR archive (files and folders) can be presented in two different modes: as text or as tree. If you set the JAVAINFO_ENTRIES_MODE variable to text then the entries are printed as plain text which can be copied into a text editor for example. If it is set to tree then the hierarchies of the JAR file system are directly presented. Extraction can be performed no matter the presentation mode. When in tree mode then the tree may be expanded automatically once the tree has been populated by JarInfo (see JAVAINFO_ENTRIES_EXPAND_TREE). The Extract button can be (de)activated by setting the JAVAINFO_ENTRIES_SHOW_EXTRACT variable to the desired value.
Most Java developers use Ant build scripts for the packaging and distribution of their applications and libraries. The simplest way to add the JarInfo component to an own JAR archive is to extract the original jarinfo.jar archive into a temporary directory (see the unzip Ant task), copy your own jarinfo.properties file over the extracted original file, let the jar Ant task include this directory in addition to the other resources, and set the main class in the META-INF/MANIFEST.MF to com.lf.commons.info.JarInfo. It's simple as that.
A sample Ant build script showing these steps and a sample jarinfo.properties file showing entries as text look like this:
Sample Ant build target to create a JAR archive including JarInfo (download build-sample.xml)
Sample jarinfo.properties file (download jarinfo.properties)
For Windows and Mac OS systems a simple click or double-click on a JAR file from file system browsers like the Windows Explorer or Finder opens the archive. The JarInfo main class is then executed automatically. If the systems lacks a graphical environment then JarInfo prints some data on the command line. This works if a suitable Java runtime environment is installed on the target platform. The JarInfo component currently requires Java 1.4 or newer.
The JAR archive including JarInfo can be executed from the command line using the following command:
Java 1.4+: java -jar [JAR file]