Solution Advices

Typical solutions for reference


Java language is a simple and convenient language, so it is good for tool softwares or game softwares, you can write a useful tool software easily and quickly. Java language is also powerful and stable, so it is also good for server softwares, which will run as a server for a long time stably.

Jar2Exe has many powerful functions to use in different kinds of java redistribute solutions. Here are some advices for typical solutions. The demos here are not only demos, they are also useful tools in practice.

About application types

There are 3 types of applications can be generated by Jar2Exe:

 Console type: When this type of application runs, the console window will be attached or created. User can interact with program through console. This type of applications are usually started at command line, with arguments if required.

 Windows GUI type: This type of applications are usually started from shortcuts by mouse clicking. When this type of application runs, there is no console window to be created. The outputs of System.out and System.err will not be visible, but the outputs can be redirected to a file or a pipe.

 Service type: This type of applications run in background. They can automatically start up when System starts up, without user login. This type of applications usually do a service on the network or do some background tasks.

About Java Runtime Library (JRE)

When generated exe runs, JRE is required. You can select to tell your customers to install JRE by themselves, or you can copy a 'jre' directory along with your program, and pack your program and 'jre' into install file together.

If your software is a small software, which is put online for download, it is preferred to tell your users how to install JRE.

If you want your software can run on a pc without JRE "installed", you can select to copy a 'jre' along with your program and pack them into install file together.

About encryption

Your java program can be encrypted and hidden into generated exe files, so user cannot extract it from exe file.

In most cases, your program will continue to run normally after encrypted. In certain cases, when your main program or a third-party library uses ClassLoader explicitly, you may need to make a little change to your code, to use another ClassLoader, in order to be compatible with encryption.

About 32 bits and 64 bits

32bits of generate exe files, with 32bits JRE only, can run on both 32bits and 64bits of OS.

Usually, you can redistribute your product as 32bits of exe file with 32bits JRE in order to run on both 32bits and 64bits of OS. If your program uses a memory larger than 1.4G, you must run your program as 64bits of exe file with 64bits of JRE.

Advices with live demos

These are some typical solutions of java program with Jar2Exe.

Advice Description Links

 Console tool

This advice shows you: How to write a console tool software to run at command line? How to print usage messages? How to prompt user to download java runtime environment?

The demo software is a tool to process svn dump file. It may be useful for someone in special situation. :)


 Live demo

 Desktop window

This advice shows you: How to write a window tool software using JSwing? How to show a splash window?

The demo software is a test tool for Regular Expressions in Java.


 Live demo

 Background service

Background service is running in background. It will continue to run when user logout. It can automatically start up when Sysem starts up without user login. This advice shows you: How to write a service program? How to redirect System.out as daily log files?

The demo software is a ftp server to run as a service. 


 Live demo


If you have a webapp (".war") file, and you want to encrypt it and wrap it into an exe file, Jar2Exe can help you do that. This advice shows you: How to compile, encrypt and wrap a webapp step by step? How to run a webapp as a standalone server or run a webapp as a background service?

The demo webapp is copied from Tomcat/webapps/examples.


 Live demo


To encrypt a JavaFX program need some special steps. This advice shows you: How to encrypt a JavaFX program step by step.

The demo software is a calculator using JavaFX.


 Live demo

 More safety

This advice introduces the differences between Jar2Exe and some other third-party softwares, and how to use Jar2Exe and some third-party softwares together in your solution to let your java program more safe.


Mac ".app" folder

This advice introduces how to put generated binary file into an ".app" folder to be a Mac app.




When i run exe file then it

When i run exe file then it gives Java Runtime Environment not found

JRE is required

1. When generated exe file runs, JRE is required.

2. Please make sure the 32bits or 64bits of exe and JRE match, 32bits of exe runs with 32bits of JRE, 64bits of exe runs with 64bits of JRE.

Working directory on Mac


my Java Application has to read and write files located in sub folders from the current directory of the executable itself. This are NO resource files but own document files.

When I create an executable for MAC and start it from the terminal with ./prgrammname everything works fine. But if I start it by double click from the mouse the subfolders are not found. Looks like there is a problem with the working directory.

How can I solve this?


Use forcecwd

Use 'forcecwd .' in configuration file to set the "current working directory" to be the same folder as the binary file.

need solution...without installing JRE

After converting Jar file to exe, without installing JRE. I just want to place extracted JRE in the path of Program files.
# path : C:\Program Files\Java\jre1.8.0 ,But exe file is not working by this method.

Is there any other way to use Converted exe file without installing JRE( copy extracted JRE files in the path : C:\Program Files\Java\jre1.8.0) ??.

Classloader and resources

Hello I am having problems extracting a zip file out of a jar I have as a resource.  I can extract it but the names of the files and directories are obfuscated.  On this page you mention "program or a third-party library uses ClassLoader explicitly, you may need to make a little change to your code, to use another ClassLoader, in order to be compatible with encryption.", can you explain how to do this?  I am attempting to extract the jar like this currently:

   File dstFile = new File(outputPath, newFileName);
   InputStream resource = Myclass.class.getResourceAsStream("/MyJarToExtract.jar");
   FileOutputStream outStream = new FileOutputStream(dstFile);

   byte[] buffer = new byte[1024];
   int bytes;
   while ((bytes = != -1) {
    outStream.write(buffer, 0, bytes);
   dstFilePath = dstFile.getAbsolutePath();
   return dstFile;

I'm going to deploy a new release for this point

Right now Jar2Exe is not compatible with codesign on Mac. I have already resolved this problem and the new release is going to be finished soon, maybe within days or weeks.

Java Exe with Derby DB


I just purchased your product and need to have an exe for my java program which also uses Derby DB.  I used netbeans, so the Dberby DB has it's Folder for the DB.  Will jar2exe include the Dberby??  How should the jars and dependent Derby DB be included?


Thanks - Tony

Yes, Derby db can be included into exe file

Hi Tony,

I have just replied your another comment here:

Yes, the Derby database can be put into exe file, but the database becomes readonly. If you need your Derby to be Readable and Writable, you need to put the Derby database outside in a directory.

Please take a look at this demo :

Thank you very much for your purchasing.

Bundled JRE


I downloaded the trial version yesterday and am trying to create a single Windows XP 32 bit executable. I need to include a main jar file, 3 dependent library jars, and a bundled JRE. Can you clarify what the settings should be to include the bundled JRE? From the "Config Internal" button and the "JRE" tab, I selected "Bundled JRE './jre'" and "Relative Path". It creates the exectuable without error, and will run correctly as long as the executable is in the same folder as the JRE. However, when I copy my executable to a different location, I receive the error "Java Runtime Environment not found". What do you recommend?

My directory structure looks like this:

- bin

   |- myExecutable.exe

   |- myExecutable.jar

   |- jre

   |- lib

       |- 3 library jars


Thank you,



You can specify the 'jre' through relative path from executable

1. The 'jre' is not wrapped into exe file, there need to be a 'jre' when exe file runs.

2. The 'jre' directory should be copied from installed jre or jdk without modification.

3. If there is a 'jre' directory along with the executable file, the executable will use this 'jre'.

4. If the 'jre' is not in the same folder of the exe file, you can specify it using relative or absolute path.

Your directory structure is correct, I could not tell exactly what's wrong, so I list some possible points. You can also contact me through email.

32bit versus 64bit


On this page is stated that a 32bit can work on both 64bit and 32bit environments. This is not 100% correct. If you have a 64bit JRE installed the generated 32bit exe file will detect the JRE correctly and the progra will fail to start. You should change the decsription on this page accordingly.

Also, a nice new feature would be to not incorporate the JAR file(s) but also allow the EXE file to simply link to the JAR file. This would create a very small EXE file just calling the selected JAR file (and it's dependencies). My project is quite large and having to incorporate all the JAR files in the EXE file would be a pain. It does seem that I only have to select the main JAR and does actually seem to pick up on the dependencies correctly after that. Anyway, linking would be really good to have..

Best regards,

Robert Jan van der Waals

Thank you very much for your comment

Dear Robert,

Thank you very much for your comment. About the first point, I have modified the description. Yes, 32bits exe can only run with 32bits JRE.

About your second point, thank you for your suggestion. In future releases, I will let Jar2Exe be able to create a pure starter without a jar in it. Right now, there is an alternative method:

You can use an empty zip file as the "main JAR". Then at the "step 3: main class" step, you can ignore the warning message which tells you the "main class" may be not right. Then add all of your program as classpath.


Sswater Shi

Add new comment