In this tutorial, we will show you how to create a executable JAR – When you double click on it, it runs the defined main class in manifest file.

1. AWT Example

Create a simple AWT Java application, just display label and print out some funny characters ~

package com.mkyong.awt;

import java.awt.Frame;
import java.awt.Label;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class AwtExample {

	public static void main(String[] args) {

		Frame f = new Frame();
		f.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
		f.add(new Label("This JAR file is executable!"));
		f.setSize(500, 500);

2. Manifest.txt

Create a manifest.txt file.


Main-Class: com.mkyong.awt.AwtExample

Uses Main-Class as the entry point of this Jar file, when you double click on this Jar file, the “AwtExample.class” main() method will be launched.

Be sure that your manifest file ends with a new line, else your manifest file will not be parsed and failed to generate the Read this

Read this jar reference guide :
Be sure that any pre-existing manifest file that you use ends with a new line. The last line of a manifest file will not be parsed if it doesn’t end with a new line character.

3. Jar file

Create a Jar file by adding “AwtExample.class” and “manifest.txt” files together.

Assume your project folder structure as follows :


You can issue following command to create a “AwtExample.jar.

jar -cvfm AwtExample.jar manifest.txt com/mkyong/awt/*.class


C:\test\classes>jar -cvfm AwtExample.jar manifest.txt com/mkyong/awt/*.class
added manifest
adding: com/mkyong/awt/AwtExample$1.class(in = 638) (out= 388)(deflated 39%)
adding: com/mkyong/awt/AwtExample.class(in = 880) (out= 541)(deflated 38%)

4. Demo

Now, the “AwtExample.jar” is executable, double clicks on it, see the output :