Creating an Eclipse project using Maven

Reading time ~2 minutes

Maven is a build automation tool used in Java projects and excellent in handling dependencies between Java projects. Eclipse is a popular IDE used in developing Java projects. Therefore it makes Java development very productive if we can combine these two tools. How hard can it be? Well, It turns out to be a very simple task. You will also not need any extra tools to get this working. Only having Eclipse IDE and Maven installed in the system will be enough.

Creating the Maven project

First go to the directory where you want you Java project to reside. Normally this will be the Eclipse workspace directory.

$ cd /path/to/workspace

Then issue following Maven command to initiate the project creation process.

$ mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart

Maven will start creating the project using interactive mode. Enter the information it asks in project creation process. Following is a small explanation of the things asked.

  • groupid - will help to identify the project uniquely. You can enter a valid package name for this.
  • artifactid - will be the name of the jar without version.
  • version - will be the version number of the jar.
  • package - package name for the project. You can enter the same value you entered for groupid.

After this step you will have your java project created under a directory named with the given artifactid value.

Importing to Eclipse IDE

Go to newly created project directory and run the following command to generate eclipse project meta files.

$ mvn eclipse:eclipse

Now you can import the project in to Eclipse IDE. Use “Existing Projects into Workspace” option in import project dialgo box. Have a look at this article for more details.

That’s all and you can start developing your awesome Java project in Eclipse.

Resources

  1. Maven - Maven in 5 Minutes
  2. How to convert Maven based Java Project to support Eclipse IDE

Online Pomodoro Timer

An Online Pomodoro Timer you can use to practice Pomodoro Technique Continue reading

Purging Git Branches

Published on October 12, 2015

Running Clustered Integration Tests in WSO2 MB

Published on October 05, 2015