Skip to content

Generates icon files for Mac/Windows and a JavaLauncher

Notifications You must be signed in to change notification settings

michab66/jlaunch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jlgen

Yet another Java launcher generator for Windows. Unique features are:

  • The generated launcher starts an application from a JLink-generated application image.
  • Knows about (jigsaw) modules.
  • Works with Java 10+.
  • Automatically creates the necessary icon resources from a single .png image.
  • Offers a command line option to generate a Windows .ico-file from a given .png-file.
  • Offers a command line option to generate a MacOS .icns-file from a given .png-file. And this on a Windows computer! :)

Many other fine launchers exist. But after a long search we did not find one that was able to work with Java 11 and application images generated by JLink. jlgen is in use today as part of our Windows build chain for generating Java-JLink-based native Windows installers for a set of commercial applications. And no customer knows it's Java :)

In addition we had a hard time to generate Windows .ico-files and the corresponding MacOS icns-files. The existing tools didn't work or were clumsy to use, so we added this to jlgen.

Usage

Firstly, get the latest version of the jlgen executable from the project's release page.

jlgen.exe is a command line application that supports different commands. Execute jlgen to get a list of the supported commands.

How to generate a launcher -- MakeLauncher

The command MakeLauncher represents the central functionality of the software. It generates a native Windows launcher for a JLink-generated Java application image. The command line is

`jlgen MakeLauncher <target.exe> <icon.png> <application module> <start class>`.

The required parameters are:

  • The name of the target file, e.g. 'Farboo.exe'. If the .exe extension is not specified then it is added.
  • The name of an icon file that is used to generate the required icon resources in the executable, e.g. 'farboo.png'. Note that a .png file is required, no hassle with generating an .ico file. It is recommended to offer a square, high resolution image, though all sizes and resolutions will do. This image gets scaled and resized for the resolutions 16, 32, 64, 128, 256 pixels.
  • The name of the target module. That is, the name of the module that holds the main Java application. For example app.mmt.
  • Finally, the name of the Java class representing the entry point to the application. This class has to offer the Java-application's public static void main( String[] argv ) operation. An example is de.michab.app.mmt.Mmt.

A complete sample call may look like

`jlgen MakeLauncher C:\cygwin64\tmp\Farboo.exe ..\mmt-icon-1024.png app.mmt de.michab.app.mmt.Mmt`.

How to generate a Windows .ico-file -- CreateWindowsIcon

The command CreateWindowsIcon lets you create a Windows .ico-file from a given input .png-file. Internally the input .png gets scaled to square images of the pixel sizes 16x16, 32x32, 64x64, 128x128 and 256x256. The resulting .ico-file is generated in the directory of the input file, with an .ico suffix. The command line is:

`jlgen CreateWindowsIcon <input.png>`.

A sample command line is

`jlgen CreateWindowsIcon felix.png`.

This results in the creation of the file felix.ico in the same directory as felix.png.

How to generate a MacOS .icns-file -- CreateAppleIcon

The command CreateAppleIcon lets you create a MacOS .icns-file from a given input .png-file. Internally the input .png gets scaled to square images of the pixel sizes 16x16, 32x32, 64x64, 128x128 and 256x256. The resulting .icns-file is generated in the directory of the input file, with an .icns suffix. The command line is:

`jlgen CreateAppleIcon <input.png>`.

A sample command line is

`jlgen CreateAppleIcon felix.png`.

This results in the creation of the file felix.icns in the same directory as felix.png.

I have the launcher executable and the icon files, what now?

Note that the generated launcher--in our example 'Farboo.exe'--has to be placed in the existing jlink image directory hierarchy at the same position where the file jvm.dll is located. This is currently {jlink-app-root}/bin/server but this may change in coming versions of the Jdk.

In Windows Explorer the launcher is displayed with the application icon that was passed to jlgen.exe above. On a double click your application opens and joy starts :^)

The next step for professional application packing is to create a native Windows installer based on the JLink file system including the jlgen-generated launcher that has to be configured as the start application. We use the WiX toolset for this purpose, but this is a different story.

See the project Wiki for more information on the remaining jlgen commands and if you want more info on jlgen development.