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 |
Required |
To let the console window invisible, it is required to select "Windows GUI application" type. |
At Step 2, select Windows GUI |
Minimum JRE |
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 |
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:
- The demo program is from http://wpollock.com/Java/RegExLabSrc.htm
- Compile and pack the classes into a jar file: RegExLab.jar
- Start Jar2Exe, at step 1, click Browse Jar and select 'RegExLab.jar'
- At step 1, click the Min box and edit it to 1.4.2.
- At step 2, select Windows GUI application.
- At step 3, select the main class com.wpollock.regexp.RegExLab
- At step 3, click Browse and select an image file as the splash window
- At step 4, check the Encrypt and hide class files option.
- At step 4, check the Support system tray option if you need.
-
At step 6, click "Version & Message", then
- At "Product Info" tab, click Add to add a program icon.
- Click OK to close this popup dialog.
-
At step 6, click "Config Internal", then
- At Custom tab, append "forcecwd ." to set the "working directory".
- At Custom tab, append "stdout out.log" to redirect System.out to a disk file.
- Click OK to close this popup dialog.
- Click Next to create the RegExLab.exe file.
Download
- You can download this demo program here.
- solutions-all.zip - 11.3M, all solution related files in one file.
Comments
Jar2Exe doesn't work with any of provided examples
I have problem running examples from solutions tab. None of them work. Program loads then instantly closes without any error.
JRE - Auto install
Will it be able to automatically install the JRE if the HOST machine where we install the generated installer doesn't have JAVA installed on it?
No, it cannot
You can copy a 'jre' folder along with the exe file, then the JRE does not have to be INSTALLed.
Problem with dimension
Hi,
I have problmes with dimension of my program. I use a laptop when I have your program installed and another one when usually I use my programs. If I use Jars, all works well. But if I wrap my Jar on a laptop, and I use it on the other one, the program frames are sized well but the internal program works with the dimensions I have on the other laptop.
I explain, I saw the program maximed, but if I print the dimensions of the maximed frame, it replies me "java.awt.Dimension[width=1296,height=736]". But, exeptionally, the fonts are small (that is good!).
The problem is with your wrapper, because if I use the Jar, without the wrapper, it prints 1942 x 1102.
What can I do?
Java Has Stopped Working
My jar2exe output file runs in many PC's but sometime it shows Java has stopped working in Java 7-8 Environment.So what would be the -Jmxx and -Jmxs optimum value for normal PC's
You can use 'option' to add JVM parameters
"-Jmxx" or "-Jmxs" not supported. All arguments will be passed to your main() method.
If you need to add JVM parameters such as "-Xmx2G", please use a config file with an item "option -Xmx2G", http://www.jar2exe.com/createdexe/config/option
not running on other computers
HI.
The GUI exe I created doesn't run on many other computers. It just doesn't open, or if it does open (on one), it is extreamly leggy and doesn't close even when clicking the X for 30 seconds.
It does run on my two computers that already have JRE installed.
Thanks,
Mohammad Afdal
The JRE is required when
The JRE is required when generated exe file runs. Jar2Exe is to protect java program from being extracted. Please contact me if you want to tell me more.
Java runtime not valid
I converted jar file to exe, it's running on my PC well, but on another PC running windows 10 it gives error message "Java runtime environment not valid"
Java runtime not valid on Windows Store install
I'm getting Java runtime not valid after packaging my application for the Microsoft Store. So if the application is packaged and installed using our installer, it works fine on Windows 10, but if the application is pulled down from the Microsoft Store (https://www.microsoft.com/en-us/store/apps/windows) I get the error. The a JVM is not packaged within the exe. The Windows 10 system has a legitimate JVM installed.
fail in loading library
my EXe converted from Java code is running in windows 8.1, but give missing java liberary in window 10, is your produced exe support windows 10 64bit
Create a Console window to check the error message
I'm not sure which kind of 'library', is it a 'jar file' or a 'dll file' ?
You can try to create a Console program instead and you will get an error message on the console window.
What does the "library not found error" describe ?
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