How to Make a JAR File in Eclipse | Java JAR
When you wish to share your project with someone making a jar file is the best option. Here you are going to learn how to make a JAR file in Eclipse. It is fairly easy to do and doesn’t involve profound learning.
But first let me tell you a little about a jar file.
What is a JAR file
JAR is an acronym we use for Java Archive. We use it to aggregate many files into one. You can make use of it for archiving purposes although it was originally built to facilitate applets to open in a single HTTP transaction. JAR facilitates compression thereby speeding up the downloading process. The format a Java JAR is built on is exactly that of ZIP files.
Let’s find out how to make your existing project into a jar.
I have put them in the form of steps so you know exactly what to click and what not to. Where’s that spoon?
Steps on How to Make a Jar File in Eclipse
Here are the steps on how to make a jar file. You would need Eclipse for this.
Step 1: Identify which project you wish to wrap up in jar format. Be ready with your project I mean.
Step 2: Now Click on File > Export
An export dialog will pop up. It will ask you to select an Export Wizard.
Step 3: Click on Java then Jar File like this:
JAR Export window will open. Here you need to tell Eclipse which resources needs to be exported.
Step 4: On the left-hand side select the resources to export. Then click on Browse and provide a location and name of the Jar file where you wish to see the file.
Step 5: When you click on Next you will find the dialog box say JAR Packaging options. Simply click on Next.
Step 6: You will find Java Manifestation Specification dialog now. Click on Next if there’s nothing you wish to change.
When you click on Finish, Voila! the Jar file will be created.
Step 7: Go to the location where the file is there. You will see the image of a coffee cup and the file will have the name you have specified.
It’s that easy.
How to Open a Jar File
Once you have the Jar file how do you bring it to use?
What’s the opposite of export? Import. That’s right. 10 points to Gryffindor!
Step 1: Click on File> Import
An import dialog box will open.
Step 2: Click on General and then on Archive File like this:
Step 3: The Archive dialog box will open. Click on Browse and select your jar file.
Step 4: Click on Finish and you are done.
Start working on that project you just imported.
You can check out our other Tips and Tricks as well.