Java and J2EE Tutorials, Jsp and Servlet Tutorials, Spring MVC, Solr, XML, JSON Examples, Hibernate & Struts 2 Hello World projects

Friday, 2 August 2013

Create a Java Project in Maven and import it in Eclipse IDE

In this particular blog we will discuss ‘How to create a Java Project in Maven’, ‘Import maven java project in eclipse ’. and ‘create a jar from java maven project’.

Before we start lets make sure you have a working Maven Package and Java installation in your machine. To make sure if you have Java installed in your system supply following command:


To make sure you have a correctly configured Maven package supply following command.

C:\Users\nagesh.chauhan>mvn -version

Create Java project in Maven

To create a java project in maven open your command prompt and navigate to the folder where you want to create the project. Now supply following command.

C:\Users\nagesh.chauhan>cd maven-project
C:\Users\nagesh.chauhan\maven-project>mvn archetype:generate -DartifactId=SimpleJavaProject -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

You will see a screen creating Maven a specified Java Project for you.

Make Maven – Jave project to work with Eclipse IDE

Here we are done with creating a Java Project in Maven, now lets make it working with eclipse IDE. Now to convert this maven-java project to work with Eclipse IDE navigate to the parent directory of your project and supply following command.

C:\Users\nagesh.chauhan>mvn eclipse:eclipse

Now import the converted project in your Eclipse IDE, the project structure in Eclipse will look like the image shown below:

Create a jar file from maven-java project in Eclipse

Now lets see how to create a jar from java-maven project, update your pom.xml a little bit to make it package your java application.


<project xmlns="" xmlns:xsi=""



Now navigate to your project parent directory and supply following command.

C:\Users\nagesh.chauhan\maven-project\SimpleJavaProject>mvn install -Dmaven.test.skip=true

We have skipped all junit classes from packaging because those are not configured yet. You will get following output screen showing packaging process.

Now go to your Eclipse IDE and expand target folder, you will get your generated jar file there as shown in following figure.

Run the java project from eclipse IDE and you will see the output like :

In this particular blog we came across ‘How to create a Java Project in Maven’, ‘Import maven java project in eclipse ’. and ‘create a jar from java maven project’. In upcoming blogs we will see more about 'Maven', 'Spring', 'Java' and other opensource technologies.

Thanks for reading !
Being Java Guys Team

1 comment:

  1. Thanks for the lesson.
    Didn't run from command line though the way I tried.
    cd target
    java -jar SimpleJavaProject-1.0-SNAPSHOT.jar
    no main manifest attribute, in SimpleJavaProject-1.0-SNAPSHOT.jar

    wha wha wha wha whaaaaaa!


Like Us on Facebook

Like Us On Google+


Skype: neel4soft