A jar file is almost an application. But it needs libraries, and would look better with an icon shortcut. All these accouterments are possible--for MSWindows--with the SelfInstall package. Together with some build.xml magic, SelfInstall wraps Xxxx.jar into InstallXxxx.jar. When the latter is downloaded and clicked, it unwraps into a full folder with an execute-me shortcut that can be copied to anywhere.
Installing from an InstallXxxx.jar file
To install from an InstallXxxx,jar, the user puts it in the desired application directory and clicks it. After installation InstallXxxx.jar can be deleted. A short cut is created; it can be copied to a menu or the start page and will continue to work to start the application.
The code
src |
Jdoc |
class |
note |
package physpics.com.tools.selfinstall
|
 |
 |
SelfInstall.java |
Is executed for a click on an InstallXXX.jar file.
Extracts the files to be installed and builds the shortcut |
The SelfInstall incorporates jshortcut
to write the shortcut icon file to the installation directory.
Example: For apps/fontviewer, InstallFontViewer.jar installs these files
417 META-INF/MANIFEST.MF
1039 com/physpics/tools/selfinstall/Pictools.properties
9130 com/physpics/tools/selfinstall/SelfInstall.class
62464 jshortcut_amd64.dll
146944 jshortcut_ia64.dll
58368 jshortcut_x86.dll
5644 net/jimmc/jshortcut/JShellLink.class
2746 README.txt
22382 FontViewer.ico
26354 fontcategories.txt
JShellLink chooses the dll based on the destination archittecture.
Making an icon
The project's distsrc directory is a good place for a Window's icon file.
The icon file should be an .ico file containing icons at sizes 16, 32, 64, and maybe 256.
The icon file needs to be announced in distsrc/Proto.properties with a definition for
project.shortcut.icon: distsrc/iconfilename.ico
I create .ico files with ImageMagick 6.9.9-11 Q16 x86_64 .
If the icons have white where they should be transparent, the Imagemagick command is
convert icon16x16.png icon32x32.png icon64x64.png \
-transparent white -colors 256 icon.ico
Adding segments to the installer manifest
A client build.xml may add sections at
the end of the Manifest for the installer.
It does so by over-riding target
-add-manifest-section with tasks that include <manifest ... mode="update"> . The task that writes additional sections for each extra entry point looks like this:
<manifest file="${manifest.file}" mode="update">
<section name="${cmdpath}">
<attribute name="Shortcut-Icon" value="lib/${iconname}"/>
<attribute name="Shortcut-Name" value="${cmd}"/>
<attribute name="Jar-File" value="${project.name}.jar"/>
<attribute name="Arguments" value="@{install.shortcut}"/>
</section>
</manifest>
"The vale of the name attribute is a relative name of a directory or file in the jar. The value does not begin with a slash; the first name element is one of the names at the top-level within the jar. Example
Name: com/physpics/tools/xxxx.class
Creating InstallXxxx.jar
InstallXxxx.jar is created and uploaded by tools/makesite.xml. See tools/makesite.html.
|