How to deploy java application and to create setup for windows

Andason Kilovele
By -
0

Deploy java application


Welcome to AndasonMajid!
In this article, I’ll guide you step by step on how to deploy your Java application and create a Windows setup (.exe) installer that includes all the required dependencies.

Back in 2015, while studying at Ruaha Catholic University, I developed a simple Java application called Mchepuko. Since then, I’ve built many small Java projects using different IDEs. During my early days of programming, I mostly used Eclipse to develop and run my applications directly from the editor.

However, one day a question crossed my mind:

What if a client requests software how can I deploy my Java application so it runs smoothly on their computer without requiring them to install anything extra?

As we know, Java applications depend on the Java Runtime Environment (JRE). For most users, installing separate components like JDK or JRE can be confusing. So, I wanted a way to package my application together with the JRE to make the installation simple just like any other Windows software.

After several days of researching online, I finally found a practical solution that worked perfectly. Since then, I’ve used it to build standalone Windows installers that include both the Java application and the embedded JRE.

Today, I’ve decided to share this approach with other Java developers who are looking for an easy and professional way to deploy their desktop applications.

In the next sections, I’ll show you how to move from your source code to a fully embedded Windows setup, step by step.

Before we begin, I assume you already have basic knowledge of Java and experience using an IDE such as Eclipse, NetBeans, or IntelliJ IDEA.


 Step 1: Test and Export Your Java Application as a Runnable JAR File

Before creating your setup file, ensure that your Java application runs perfectly and has been fully tested. This helps you avoid rebuilding the project later due to minor errors or missing components.

Once everything is working correctly, follow these steps in Eclipse:

1.      Go to the top menu and click File → Export.

2.      When the Export dialog appears, expand the Java folder.

3.      Select Runnable JAR File, then click Next.

This will allow you to package your project into a single executable .jar file that can be run outside the Eclipse environment.




Step 2: Configure and Export the Runnable JAR File

After selecting Runnable JAR File and clicking Next, you’ll be redirected to the export configuration dialog (as shown below).

In this dialog:

1.     Under Launch configuration, select the project you want to deploy.

2.     In the Export destination field, browse to the folder where you want your exported JAR file to be saved.

3.  Under Library handling, choose the option “Extract required libraries into generated JAR”.

4.     Finally, click the Finish button.

Once the export process is complete, the Runnable JAR file will be generated and saved to the folder you specified.

(See the screenshot below for reference.)



Step 3: Convert the JAR File to an Executable (.exe) Using Launch4j

At this stage, you should have your Runnable JAR file ready. You can run it to confirm that everything works as expected. Once you’ve verified it’s running properly, it’s time to convert your JAR file into a Windows executable (.exe).

For this process, you’ll need two tools:

  • Launch4j: to convert your .jar file into a .exe file.
  • Smart Install Maker: to create a professional Windows installer later.

Let’s start with Launch4j.

After launching the Launch4j application, you’ll see a configuration window (as shown below). Here’s how to set it up:

1.     Basic Tab:

1.     Specify the Output file location (where your .exe file will be saved).

2.     Select the .jar file you want to convert.

3.     (Optional) Add an application icon if you have one.

2.     JRE Tab:

1.     In the Bundled JRE path field, enter the exact directory path where your JRE will be located.

2.     This path tells your application where to find the Java Runtime Environment when it runs.

3.     Note: The same path will be used later when creating the installer using Smart Install Maker.

Once all required fields are filled, click the Build Wrapper button.
Launch4j will then generate your .exe file, converting your Java application into a standard Windows application.

(See the screenshot below for reference.)



Step 4: Create a Windows Setup File Using Smart Install Maker

At this point, you have a .exe application that runs on Windows. However, it won’t work yet because the JRE (Java Runtime Environment) isn’t available in the path you configured earlier in Launch4j.

To solve this, we’ll use Smart Install Maker to create a Windows setup (.exe) installer that bundles your application together with the JRE. During installation, the JRE will be placed in the exact path you specified in Launch4j, ensuring your application runs seamlessly on any computer even if Java isn’t installed.

Before we begin, follow these preparation steps:

  1. Create a new folder on your computer.
  2. Inside that folder, paste the .exe application you generated using Launch4j.
  3. Also paste the JRE folder (I recommend using the 32-bit JRE version, as it works on both 32-bit and 64-bit Windows systems).

Your folder should now contain two items:

  1. The .exe application file
  2. The JRE folder

(Refer to the screenshot below showing the prepared folder structure.)

Once that’s done, open Smart Install Maker to start building your setup file. In the next step, you’ll configure it to include both your application and the JRE, creating a single installer that users can easily install and run without needing to install Java manually.

 




Step 5: Configure Smart Install Maker to Build the Setup File

The screenshot below shows how to use Smart Install Maker to build your setup file.

i. Under the “General” tab:
Fill in the basic information about your application, such as:

  • Product Name: the name of your software (e.g., Mchepuko).
  • Version:  your software version number (e.g., 1.0).
  • Company your organization or developer name.
  • Website / Copyright optional fields for additional details.

This information will appear in your installer and help identify your application professionally.

(See the screenshot below for reference.)

 




ii. Under the “Files” tab:
In this section, you’ll add the actual files that will be included in your installer.

·   Click Add Folder and select the folder you created earlier the one containing both the .exe application and the JRE folder.

· This ensures that when the setup is built, both your application and the JRE are packaged together and installed to the correct location on the user’s computer.

(Refer to the screenshot below for visual guidance.)

 


iii. Under the “Requirements” tab:
Here, you can specify the minimum Windows version that your application will support.
For example, you may choose Windows 7 or any newer version depending on your target users.
This ensures your installer runs only on compatible systems and avoids installation issues on unsupported Windows versions.

iv. Under the “Dialogs” tab:
This section allows you to customize the installation experience for users.

1.       Destination Path: Enter the installation path for your application.
Make sure this path matches the one you configured in Launch4j.
For example:

                               i.       If in Launch4j the JRE path was C:\Program Files\APS\jre

                              ii.     Then in Smart Install Maker, set the destination path to C:\Program Files\APS

2.       License Agreement: You can attach a license file if you want users to accept terms before installation.

3.       Password Protection: Optionally, you can set a password if you want to restrict access to the installer.

4.       Finally, check the “Enforce Path” checkbox  this ensures users cannot change the default installation location during setup.

(Refer to the screenshot below for proper configuration layout.)


v. Build the Installer

After completing all the required information and settings in Smart Install Maker, click the “Build Installer” button. The software will generate a Windows setup (.exe) file that

  1. Installs your application on the specified Windows operating system,
  2. Includes the embedded JRE, so users do not need to install JDK or JRE separately,
  3. Ensures your application runs smoothly right after installation.
Thank you

 


 










Post a Comment

0 Comments

Post a Comment (0)
3/related/default