Solution Advice: Desktop window

A desktop window program is to display a window from Java, usually without a Console window


Introduction

If your java program will show a window as your program's user interface, this advice will show you typical solutions with Jar2Exe.


Solution

This type of desktop window program is usually started from a shortcut, not from command line, and usually the console window is not needed. So we should create a "Windows GUI application" from Jar2Exe. It is better to select a custom program icon, which will also be the icon of the shortcut. It is more friendly to show a splash window before main window opens, to tell user program is starting.


Features used

We advise you to use following features:

Feature Advice Introduction How to enable

GUI application
type

Required

To let the console window invisible, it is required to select "Windows GUI application" type.

At Step 2, select Windows GUI

Minimum JRE
version

Recommended

If you use a feature since certain version of JRE, you'd better set a min JRE version.

At Step 1, select a Min version

Encryption

Recommended

If you want to protect your program from being extracted and decompiled, you can select to encrypt it.

At Step 4, check the encrypt option

Splash window

Recommended

To display a splash window is more friendly. This can tell user the program is starting.

At Step 3, select a picture

Program icon

Recommended

A desktop window program is usually started from a shortcut, so the program icon will also be the icon of the shortcut.

At Step 6 > Version & messages

Force CWD

Optional

If your program need to run in a certain "working directory", you can enable "Force CWD" to ignore the start position.

At Step 6 > Config Internal > Custom tab, use a 'forcecwd' item

Stdout redirect

Optional

Because the console window is not visible, if you need to get the content of System.out, you can redirect it  to a disk file.

At Step 6 > Config Internal > Custom tab, use a 'stdout' item

System tray

Optional If your program will run for a long time and you want it keep running after window is closed, you can minimize it to a System tray. At Step 4, enable System tray, then use Integrate API to create

Steps

Steps of this advice:

  1. The demo program is from http://wpollock.com/Java/RegExLabSrc.htm
  2. Compile and pack the classes into a jar file: RegExLab.jar
  3. Start Jar2Exe, at step 1, click Browse Jar and select 'RegExLab.jar'
  4. At step 1, click the Min box and edit it to 1.4.2.
  5. At step 2, select Windows GUI application.
  6. At step 3, select the main class com.wpollock.regexp.RegExLab
  7. At step 3, click Browse and select an image file as the splash window
  8. At step 4, check the Encrypt and hide class files option.
  9. At step 4, check the Support system tray option if you need.
  10. At step 6, click "Version & Message", then
    1. At "Product Info" tab, click Add to add a program icon.
    2. Click OK to close this popup dialog.
  11. At step 6, click "Config Internal", then
    1. At Custom tab, append "forcecwd ." to set the "working directory".
    2. At Custom tab, append "stdout out.log" to redirect System.out to a disk file.
    3. Click OK to close this popup dialog.
  12. Click Next to create the RegExLab.exe file.

Download

Comments

Library not found

I created an application from jar file to exe with Jar2exe and created setup with Inno Setup.   After installation in other laptop, it has library not found error.  Is there any way to find out what library is missing?   Is there any way to setup URL for user to download when library missing?
Thanks.
Henry

Add new comment