This tutorial details how to create a JAR File Using Maven in Eclipse. I.e. if you want to generate a JAR as the result of your Maven Install command then this tutorial is for you.The created JAR can be included as a dependency in a different project and becomes reusable.
Pre-requisite for this tutorial – The Eclipse plugin “Maven Integration for Eclipse (Juno and newer)” should be installed in your copy of Eclipse IDE.
Lets start off the with the tutorial then.
Step 1: In Eclipse Juno, click on File >New >Other and Select “Maven Project” and click “Next”…
Step 2:The following “New Maven Project” dialog will be displayed. If you want to store the project in the default workspace location then nothing needs to be done on this screen. Click “Next” to move to the next screen…

Step 2A: In case you do not want to store your project in the Default Workspace location then you need to unselect the “Use Default Workspace” checkbox and click on “Browse”. You can select the folder to store your project in the “Selection Location” dialog box…

Step 3: Next the Archetype Selection dialog is displayed in the wizard. Select the “maven-quickstart-archetype”, which is the bare minimum archetype for creating a sample project, and which is exactly what we need for creating a JAR. It has the following structure – project |– pom.xml `– src |– main | `– java | `– App.java `– test `– java `– AppTest.java Note – Eclipse may download the latest version of the archetype before it takes you to the next screen. It will display a message at the bottom of the dialog if it does that…<br>

Step 4: You will be shown a configuration dialog where you need to enter the “Group Id”,”Artifact Id”, “Version” and “Package” for your maven project…

Step 5: Fill these up as shown below… (Note that the Package field is auto-populated as a concatenation of GroupId and Artifact Id. But you can edit it if you want to)

Step 6: Click on “Finish” to finish generating your Maven project…

