How to make an executable Jar file in Java

Jar file


A jar file is simply a file containing a collection of java class files.

To make a jar file executable, you need to specify where the main Class is in the jar file. Example code would be as follows.

Compile your classes. To make a jar, you also need to create a Manifest File (MANIFEST.MF).

Place the compiled output class files (JavaClassName.class,JavaClassName$1.class) and the manifest file in the same folder. In the command prompt, go to the folder where your files placed, and create the jar using jar command. For example (if you name your manifest file as

An undergraduate student at Mumbai University majoring in computer science. I believe in writing for self reflection and reading for self development.