leisenfels mit schrift und slogan 48

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

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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Copyright (c) 2005-2023 Leisenfels GmbH. All rights reserved.
# Use is subject to license terms.
#! encoding=ISO-8859-1 Unicode Escapes
# Window and appearance
#JAVAINFO_LOCALE=(auto|en|de) (Default: auto, fallback is current system locale, then English)
#JAVAINFO_PLAF=(auto|com.apple.laf.AquaLookAndFeel|...) (Default: auto -> current system look & feel)
#JAVAINFO_WINDOW_TITLE=[e.g. "JarInfo"] (Default: JarInfo)
#JAVAINFO_WINDOW_ICON=[e.g. "resource/cubes_16.png"] (Default: none = Java cup)
#JAVAINFO_WINDOW_WIDTH=[e.g. 640] (Default: 580)
#JAVAINFO_WINDOW_HEIGHT=[e.g. 480] (Default: 420)
#JAVAINFO_WINDOW_LOCATION_X=(value|center) (Default: center)
#JAVAINFO_WINDOW_LOCATION_Y=(value|center) (Default: center)
#JAVAINFO_INITIAL_TAB=(notice|manifest|entries|services) (Default: not set = first tab)
# File path (top)
#JAVAINFO_SHOW_FILENAME=(true|false) (Default: true)
#JAVAINFO_FILENAME_MODE=(fullpath|nameonly) (Default: fullpath)
# Copyright (bottom)
#JAVAINFO_SHOW_COPYRIGHT=(true|false) (Default: true)
#JAVAINFO_COPYRIGHT=[e.g. "Copyright (c) 2011 MyCompany.com"] (Default: not set = JarInfo copyright)
# Notice tab
#JAVAINFO_SHOW_TAB_NOTICE=(true|false) (Default: false)
#JAVAINFO_NOTICE=[e.g. "This is a Java library archive."] (Default: not set = localized notice text)
# Manifest tab
#JAVAINFO_SHOW_TAB_MANIFEST=(auto|true|false) (Default: auto)
#JAVAINFO_MANIFEST_MODE=(plain_wrapped|plain_unwrapped) (Default: plain_unwrapped)
# Files tab
#JAVAINFO_SHOW_TAB_ENTRIES=(true|false) (Default: true)
#JAVAINFO_ENTRIES_MODE=(text|tree) (Default: text)
#JAVAINFO_ENTRIES_EXPAND_TREE=(true|false) (Default: false)
#JAVAINFO_ENTRIES_SHOW_EXTRACT=(true|false) (Default: false)
# Services tab
#JAVAINFO_SHOW_TAB_SERVICES=(auto|true|false) (Default: auto)
#JAVAINFO_SERVICES_AUTO_SELECT=[e.g. "com.lf.commons.i18n.spi.Localization"] (Default: not set)

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.

1
2
3
4
5
6
7
8
9
10
<html>
 <table>
 <tr>
 <td><img src="%information_32.png%"/></td>
 <td> </td>
 <td>Dies ist ein Java-Archiv, das nicht direkt ausgef\u00FChrt werden kann.<br>
Bitte entnehmen Sie den korrekten Aufruf der Programm-Dokumentation.</td>
 </tr>
 </table>
</html>

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 class and the *.properties resource files over to your own project source code.

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.

 


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]

Print Email


Cookies make it easier for us to provide you with our services. With the usage of our services you permit us to use cookies.
Ok