A JAR (Java Archive) file is a ZIP format file that bundles Java classes into a single unit. There are two types of JAR file in Java:

Create a normal JAR file:

Right click on project name in Project Explorer view, select Export… (or select Export… from File menu):

select export

 

In the dialog Export, select Java > JAR file:

select JAR file

 

 



Click Next. In the screen JAR File Specification:

 

Click Next. In the next screen, we can select an option to save export information so that we can re-create the JAR file later without redoing the previous steps:

 

Click Finish. All class files of the project are exported to a JAR file and a JAR description file is created, under project’s root directory:

jar file exported

Note that the file ends with .jardesc is the JAR description file which stores the information we have specified in the wizard. And we can use it as a shortcut whenever we want to re-export the JAR file.

Right click on the .jardesc file, select Create JAR:

context menu create jar

 

Create an executable JAR file:

Creating an executable JAR file is same as creating a normal JAR file, except it requires to specify a main class. In the screen JAR Packaging Options, click Next will take us to the screen JAR Manifest Specification:

create executable jar file

 

In this screen we can:

 

Click Finish, the executable JAR file is created.

 

Other Eclipse Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.