Create Windows Executable (.exe) for Java Application

Launch4j is a cross-platform tool for wrapping Java applications distributed as jars in lightweight Windows native executable files. In this post, we will learn making such an executable file for a demo java application.

Step1 ) Create a java application

I am creating a very basic java class which simply displays a frame and some text on it. It also has the main() method which will start the application.

package com.howtodoinjava;

import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Label;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JDialog;

public class ApplicationMain extends JDialog 
	private static final long serialVersionUID = 1L;
	public ApplicationMain() 
		//Create a frame
		Frame f = new Frame();
		f.setSize(500, 300);
		//Prepare font
		Font font = new Font( "SansSerif", Font.PLAIN, 22 );
		//Write something
		Label label = new Label("Launch4j Maven Demo with");

		//Make visible
		f.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
	public static void main(final String[] args) 
		new ApplicationMain();

Step 2) Create maven file with launch4j configured in it

I have created a pom file for packaging the application as .exe file. If you feel something unclear, drop a comment.

<project xmlns="" xmlns:xsi=""
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">

Step 3) Create .exe file

To make the exe file for above java program, run maven command:

mvn package

Above command will create the “howtodoinjava.exe ” file in your project’s target folder. Double click on .exe file will open the window like this.

Launch4j maven demo to create java executable
Launch4j maven demo to create java executable


If you want to download source code of above application, click on below given download link.

Sourcecode Download

Happy Learning !!


Notify of
Most Voted
Newest Oldest
Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.

Our Blogs

REST API Tutorial

Dark Mode

Dark Mode