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.
Then issue following Maven command to initiate the project creation process.
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.
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.