How to Use JarInfo
Please read the following steps to add the JarInfo component properly to your Java library archives:
- Step 1: Download Maven Project
- Step 2: Prepare javainfo.properties
- Step 3: Adding The Component To JAR Archives
- Step 4: Testing
Step 1: Download Maven Project
First of all please download the current JarInfo project onto your computer. It can be extracted with WinZIP or other ZIP extraction tools. The archive contains a Maven pom.xml file to be imported into you favorite IDE.
Please install a Java SDK capable of generating 1.4 compatible class files (e.g. Oracle JDK 1.4.2_08) and configure the path of this Java SDK in file pom.xml (change and uncomment JDK14_HOME property).
Run mvn clean package, executable JAR is being created in target subfolder.
Open it in Windows by double-clicking the JAR file in Windows Explorer, Swing-based dialog is displayed.
Step 2: Prepare jarinfo.properties
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:
1 |
# Copyright (c) 2005-2023 Leisenfels GmbH. All rights reserved. |
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.
Step 3: Adding The Component To JAR archives
Copy the JarInfo classes and the *.properties resource files over to your own project source code, keep the packages.
Adjust jarinfo.properties for your needs e.g. set customized dialog icon.
Create your library JARs with JarInfo as main class in META-INF/MANIFEST.MF and include customized resources.
Double-clicking these files in Windows Explorer will open the Swing-based dialog based on your settings.
Please see the sample.jar example on how JarInfo resources need to be included in own JAR files.
Step 4: Testing
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]