Executable Java Jar File and Windows Exe File Creation

How to create an executable java jar file? I want to just double click the jar file and the application should run, please help me. I want to convert my java application to a windows exe file, how can I do it? These are two frequently asked questions.

For you guys who know about these things already you may skip this article, as there is no surprise element embedded. For us who are interested in learning new things go ahead, anything new adds up.

How to Create an Executable JAR File?

JDK gives us a tool to create jar files.


Before creating a java jar file, we need to create a java manifest file.

Command to create an executable java jar file:

jar -cvfm BundleExample.jar manifes
t.txt com/javapapers/corejava/*.class

How to create a java manifest file?

Generally we will have the manifest file located in,

  • META-INF/manifest.mf

This manifest file contains information about the jar file. Information like which is the main java class to be executed, who created the application, version of the application, etc.

It is a regular text file. Remember to press enter at the end of each line and importantly in the last line.

So with respect to creating an executable java jar file, we need to add the main class of the application using which it can be launched. Our example manifest file is like below,

Main-Class: com.javapapers.corejava.JavaBundleExample

This is the only line I have and that is sufficient for our purpose.

Ads by Google

Sample Application

We need a sample java application to enjoy this. Lets create a simple hello world type swing application.

package com.javapapers.corejava;

import java.awt.GridLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class JavaBundleExample {

	private static void createAndShowGUI() {

		JFrame frame = new JFrame("Bundle Example");
		JPanel pane = new JPanel(new GridLayout(0, 1));
		JButton button = new JButton("Dummy Button!");
		JLabel label = new JLabel("Example for Bundling JRE with Java Class");
		pane.setBorder(BorderFactory.createEmptyBorder(30, 30, 10, 30));

	public static void main(String[] args) {
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {



Just execute the following line (command) to create the jar file, you should have added JDK to PATH.

jar -cvfm BundleExample.jar manifes
t.txt com/javapapers/corejava/*.class

Now we can double click the jar file and the application will launch and run.

How to Create a Windows Exe file?

If we create a windows native exe file, then we loose the platform independent-ness.


Let us use a tool called Launch4J. It’s a nice tool, works good and easy to use.

Its core features are,

  • creating lightweight Windows native EXE
  • JRE version control
  • app icon
  • splash screen
  • process name
  • Java download page

Download Launch4J and use the GUI to create the windows/Java exe file. Launc4J creates an XML file to save the configuration.


  • I have specified the output file, this is the name of the exe file to be created.
  • Jar is the input file which we want to bundle as an exe file. Lets use the Java JAR which we created in the previous step.
  • In JRE tab, we can specify the Min JRE version required. So this will detect the JRE available in the system and verify if the version is sufficient.
  • Click the cog wheel icon from the menu to generate the exe file.

This Core Java tutorial was added on 07/04/2013.



Comments on "Executable Java Jar File and Windows Exe File Creation"

  1. Hi says:

    Sucks….. Please give the complete detail with cmd commands

  2. Arun says:

    Dear sir ,
    How to convert uhtm file into html file

  3. kaushik says:

    I created a .exe file but I’m not able to execute it help me out.
    And will that exe run if d program needs arguments that are taken from command line argument

  4. Soumalya Dutta says:

    Launch4j is not useful at all,it just changes the extension nothing else

  5. Rohit says:

    In Runnable Jar Part:

    I have done the way it is said,
    It Didn’t work initially, But
    It started working after I added
    Class-Path: . in the manifest file

    • Rohit says:

      This article has helped me. Simple and clearly explained. I have been searching for this content from long back

  6. chinnadurai says:

    iam chinna
    welcome to this article

  7. Padda says:

    Did everything given here but generated .exe file not able to execute… Help me

  8. Rob says:

    Hi Joe,

    Well I think I’ve tried everything. I reinstalled both Java and the JDK (with NetBeans), and that all works fine. I can run my Jar file in the Windows (7) command window by typing: java -jar myprog.jar

    However, I want to be able to start my program by double-clicking it. I did “open with” and the browse and choose ….javabinjava.exe but it does nothing. I think that is because I can’t add the “-jar” part. Ugh!!

    Again this works from the command line, with the -jar of course. I read on-line somewhere that I should edit the registry – I don’t know enough about that and don’t want to “mess up” anything, plus, it can’t be that hard!, I just want it to execute the jar when double-clicked. The computer “should” be smart enough to know ‘ “Oh, .jar file, I think I’ll run it with java -jar”.

  9. arjndah says:

    love… great.

  10. Anonymous says:


  11. Krishnaraj M says:

    Hi Joe,
    Thanks for the information about Self extractable Jar file.Is it possible to create a Exe file,which contains the Self Extractable Zip.For example,I have a link to download EXE file.After downloading EXE,when i open,It should extract the Zip content and ask the user to select the store location.

    I tried and googled lot,But i dont know how to implement this.Will you give some inputs or suggest me .Is there any way to implement this?

  12. Deepak says:

    Very useful article.. Thank you !!

  13. Akashdeep Singh says:

    Useful tutorial. Thanks for his. This method works. But what if I want to make an exe from a jar which is self-sufficient, i.e., does not need JRE installed. I searched a bi about this and found this: http://jnc.mtsystems.ch/
    Java native. The thing is I dont get how to operate it. Can you help?

  14. Ramesh kumar says:

    Really its very useful to everyone as well as designed in nice….. Thank you….

  15. sushil kumar says:

    Thanks, I have doubt how to create .exe and how to show with icon. It’s great…..

  16. Jishnu L says:

    Great article. I was under the impression that jar file to exe is not possible.

  17. prashanth says:

    hello mr.joe,

    iam new to this site after going through your site iam very pleased.

    many thanks for spending your valuable time for people like me.

    your thinking of giving preference to core java is great.

    Thanks again from the bottom of my heart.


  18. Deepak Gakhar says:

    Thanks !!!

  19. Anand.V says:

    if we have to create a mark list program and to store a value to the back end. then how we can create a exe file for this back end process.

  20. bharat says:

    I have seen people spending hours and days to figure this out.. thanks for making it so clean and simple.

  21. Suifeng says:

    Good Job.
    Thanks sir

  22. Padma Priya says:

    I am not able to open the file.

    when i am double clicking the file i am not getting any output.

  23. Anandan R says:

    Good to know for Developers.

  24. Nishant says:

    Thanks for Sharing..
    Nice Tutorial.

  25. pradeep says:

    Useful Information.Nice Article.
    Thanks for sharing.

  26. deepak says:

    Nice and easy article,Thanks sir.
    Kindly provide jar file creation process through the eclipse..

  27. vishwajeet nayak says:

    thanks,, i am searching for it…

  28. Anonymous says:

    Excellent thing.. I have learnt a new class 2daay

  29. kalpesh says:

    very nice article

  30. Shailesh says:

    Wonderful …. Nice article :-)

Your Comment