

Going back to our example, we move to the bin directory of our project and create a file called manifest.txt as the following: Main-Class: The command accepts as input the manifest file as well as the list of compiled classes to be packaged in the jar. 2.1 Using manifest fileĪnother way to create an executable jar is through using the ‘jar’ command in the command line. In this section, we consider that you have already installed java on your machine, and you already added the java path to your PATH environment variable.

The jar holds all the compiled classes along with their packages, in addition to a folder named as META-INF which holds a file called MANIFEST.MF, this is the file which makes the jar executable, since it holds the path of the main class of the application, without this file the jar cannot be executed. If you open executable.jar (using winrar or 7-zip tools), you will get something like this: We select our main class “HelloWorld” and click finish, eclipse then generates an executable jar file called executable.jar. In the next page select your main class (Launch configuration) and name the jar file as the following: Search for Runnable JAR file, then click next. Right click HelloWorld -> Export, then you get the following screen:

Let’s consider a typical hello world example as the following:Įclipse provides a tool to generate an executable jar out of any standalone application, to do this: In this tutorial, we define the different ways to create an executable jar. A jar file is executable if it contains at least one entry point class with a main method.
