How To Create Maven Project In Eclipse? A Step-By-Step Guide
By Rohan Vats
Updated on Jun 17, 2025 | 21 min read | 9.48K+ views
Share:
For working professionals
For fresh graduates
More
By Rohan Vats
Updated on Jun 17, 2025 | 21 min read | 9.48K+ views
Share:
Table of Contents
Do you know? Maven’s central repository, with over 3.5 million packages, is one of the largest ecosystems for Java dependencies globally, and its enterprise-grade adoption is evident as over 2,000 companies rely on Maven for their software development pipelines. |
Building a Maven project in Eclipse greatly improves Java development by automating build processes and simplifying dependency management through integrated tools. Maven’s powerful project management features make configuration and maintenance seamless, ensuring consistency across different environments.
This streamlined approach allows developers to focus more on writing code and less on managing complex setups, leading to more efficient and reliable project workflows.
In this blog, you’ll learn how to efficiently create and manage Maven projects in Eclipse, an IDE for Java developers. You’ll also understand how to use Maven’s powerful features for building Java-based applications.
Eclipse IDE, with its built-in Maven support via the m2e plugin, has become the industry standard for managing Java projects. With over 84% of Java developers using Eclipse, its seamless Maven integration boosts productivity by simplifying dependency management and automating builds.
The Maven Central repository, accessible through Eclipse, hosts over 3.5 million packages, providing a vast ecosystem for Java development. This integration streamlines project setup and contributes to Maven’s critical role in enterprise and open-source Java projects, with nearly 2 billion downloads annually.
In 2025, professionals skilled in tools like Maven for automating builds and managing dependencies will be in high demand. If you're looking to develop expertise in Java development, here are some top-rated courses to help you get there:
Now, let’s get into the step-by-step process of creating a Maven project in Eclipse:
Before creating a Maven project in Eclipse, ensure that Maven is installed and configured in Eclipse. Here’s how to do it:
Now, you're ready to start creating your Maven project in Eclipse!
Also Read: Top 5 Exciting Maven Multi-Module Project Ideas & Topics for Beginners
Creating a new Maven project in Eclipse begins with setting up the project structure and configuring basic settings such as Group ID and Artifact ID.
Here’s how to do it:
Now, you'll specify the Group Id and Artifact Id:
Select maven-archetype-quickstart as the archetype, which is a template for creating a simple Java project. Click Next.
You will now have a project setup similar to the following:
my-app
├── pom.xml
└── src
├── main
│ └── java
│ └── com
│ └── mycompany
│ └── app
│ └── App.java
└── test
└── java
└── com
└── mycompany
└── app
└── AppTest.java
You can get a better hang of Java with upGrad’s free Core Java Basics course. It covers variables, data types, loops, and OOP principles to build strong coding skills. Perfect for aspiring developers, students, and professionals transitioning to Java.
Also Read: How To Create Dynamic Web Project Using Eclipse [Step By Step Explanation]
Now, you'll explore the Maven project structure, including the pom.xml file for configuration, and the src directories for source code and tests.
Also Read: Learn 50 Java Projects With Source Code (2025 Edition)
After creating the Maven project in Eclipse, you'll see a basic Java class and a test class. Let's walk through each file:
App.java (Main Application Class): Located in src/main/java/com/mycompany/app/App.java, this class is a simple "Hello World" application.
package com.mycompany.app;
public class App {
public static void main(String[] args) {
System.out.println("Hello, Maven!");
}
}
Explanation: This class defines the main method, which prints "Hello, Maven!" when executed. App.java is the entry point of the application.
Output:
Hello, Maven!
AppTest.java (Unit Test Class): Located in src/test/java/com/mycompany/app/AppTest.java, this test class verifies the functionality of the App class.
package com.mycompany.app;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class AppTest {
@Test
public void testAppHasMessage() {
App app = new App();
assertTrue("The message should contain 'Maven'", app.main() != null && app.main().contains("Maven"));
}
}
Explanation: This test class uses JUnit to test if the message "Maven" is printed when the main method is called. The test class is located under src/test/java and follows the JUnit structure for writing unit tests.
Output:
The message should contain 'Maven'
Also Read: IntelliJ IDEA vs. Eclipse: The Holy War!
Next, you'll build and run your Maven project in Eclipse using Maven commands to install dependencies and compile the code, ensuring everything is set up correctly.
1. Build the Project: To build the Maven project, you can use the Maven Goals in Eclipse.
This command will clean the project, install dependencies, and package it.
2. Run the Project: To run the project:
Hello, Maven!
Also Read: How To Create Spring Boot Project In Eclipse
Maven uses dependencies to add external libraries to your project. You can add dependencies to your pom.xml file under the section. For example, to add JUnit for testing, you can include the following dependency:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>
After adding this dependency, Maven will automatically download the JUnit library when you build the project.
Are you a full-stack developer wanting to integrate AI into your workflow? upGrad’s AI-Driven Full-Stack Development bootcamp can help you. You’ll learn how to build AI-powered software using OpenAI, GitHub Copilot, Bolt AI & more.
Also Read: How to Code, Compile, and Run Java Projects in 2025
Next, let’s look at what is POM in Maven.
Learn: Spring Developer Salary in India: For Freshers & Experienced
It is the center of Maven projects and their configuration. The pom.xml file is a configuration file that stores most of the necessary information for building a project in your desired manner. The POM file can be quite massive and complex, but it isn’t necessary to know about its technical aspects to use it properly. The POM for our project is the following:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
What happens when this pom.xml is used in a Maven project?
Output Explanation for Maven Build:
When you run the following command in the terminal:
mvn clean install
Here’s what you can expect:
Here is a simple run-through of essential POM elements:
There are many POM elements, and if you want to work on many Maven project ideas, it would be best to get familiar with them. However, you don’t need to be familiar with all of them if you’re a beginner.
Also Read: Java Language History: Key Milestones and Development
upGrad’s Exclusive Software Development Webinar for you –
SAAS Business – What is So Different?
Next, let’s look at some of the benefits of creating a Maven Project in Eclipse.
Maven’s integration with Eclipse enables developers to automate builds, manage dependencies directly from the IDE, and leverage features like real-time error reporting and one-click project setup.
Eclipse’s m2e plugin further simplifies the process, letting you run Maven goals, manage dependencies, and configure project settings without leaving the IDE.
This combination is a key productivity driver for teams and individuals building scalable, maintainable Java applications.
Here are some key benefits of using Maven Project in Eclipse:
Maven automates dependency management via pom.xml, allowing easy addition, updating, or removal of libraries without manual JAR handling. Eclipse integrates seamlessly, enabling quick access to dependencies from Maven Central while avoiding version conflicts.
Example: With a simple line in your pom.xml like this:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
Eclipse will automatically download and include JUnit in your project, without needing you to manually manage the JAR file.
Maven ensures a consistent build process across environments by standardizing project builds. In Eclipse, it manages the entire lifecycle, from compiling to packaging and deployment, making collaboration and cross-machine work seamless.
Example: By running mvn clean install, Maven will clean, compile, and install the project’s dependencies, ensuring that the build process is consistent each time it is executed.
Maven integrates smoothly with CI tools like Jenkins and Travis CI, automating builds and tests. In Eclipse, you can easily configure your Maven project in Eclipse to work with CI/CD pipelines, ensuring automated testing and deployment.
Example: After configuring Maven in Eclipse, you can integrate with Jenkins to automatically trigger builds and tests each time a developer commits changes to the version control system, streamlining the development process.
Maven enforces a standardized project structure, aligning with industry best practices. In Eclipse, this structure makes it easier for new team members to understand the project layout, streamlining onboarding and collaboration.
Example: A typical Maven project structure in Eclipse might look like this:
my-app
├── pom.xml
└── src
├── main
│ └── java
│ └── com
│ └── mycompany
│ └── app
│ └── App.java
└── test
└── java
└── com
└── mycompany
└── app
└── AppTest.java
This structure separates source code (src/main/java) from test code (src/test/java), making the project easier to navigate and maintain.
Maven simplifies version control by defining all dependencies and plugins in the pom.xml, preventing conflicts across environments. In Eclipse, this integration makes tracking changes, managing versions, and collaborating with teams easier.
Example: By managing dependencies through pom.xml, if a new version of a library is required, you can update the version in a single file, and Maven will automatically handle the rest, ensuring consistency across all environments.
Maven supports testing frameworks like JUnit and TestNG, making it easy to run unit tests, check code coverage, and generate reports in Eclipse. It also automates test execution during the build process, ensuring thorough testing at each stage.
Example: After adding the JUnit dependency in pom.xml, running mvn test in Eclipse will automatically execute your unit tests, and Maven will generate a report on the results, helping you catch errors early in the development cycle.
These features help boost productivity, improve collaboration, and ensure smooth project management, making it a top choice for Java developers.
Also Read: Best Java Courses Online (Recommended by Developers)
Next, let’s look at some of the best practices to keep in mind while creating a Maven project in Eclipse.
Following best practices for a Maven project in Eclipse ensures efficient management, streamlined dependencies, and scalable development. By using a consistent structure, managing dependencies in pom.xml, and automating builds, you maintain clean code, enhance collaboration, and reduce errors in both solo and team environments.
Here are some key strategies to keep in mind:
Stick to the default Maven directory structure, which separates source code (src/main/java) from test code (src/test/java). This helps maintain organization as the project grows.
Example: By following the default structure, when your project scales, you can easily distinguish between production code and test code. For instance, placing the main application logic in src/main/java and test cases in src/test/java makes it clear and easy for collaborators to understand the project layout.
Always specify dependencies with clear and specific versions in the pom.xml file. This prevents version conflicts and ensures that the project remains stable across different environments.
Example: By defining the version explicitly:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
This ensures that everyone working on the project uses the same version of JUnit, preventing issues caused by differing versions of dependencies.
Define profiles in the pom.xml to handle different environments (development, testing, production). This allows you to customize behavior based on the environment without changing the project structure.
Example: You can define separate profiles for development and production, which could use different configurations or dependencies, like:
<profiles>
<profile>
<id>development</id>
<properties>
<env>dev</env>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<env>prod</env>
</properties>
</profile>
</profiles>
This allows you to easily switch between environments and use different settings as required.
Manage all dependencies and plugins through the pom.xml to ensure a clean and reproducible build process. Avoid including dependencies directly in individual files.
Example: Instead of manually managing dependencies, you can rely on Maven to handle everything:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.0</version>
</dependency>
</dependencies>
</dependencyManagement>
This reduces dependency version conflicts and ensures that the right libraries are always available for your project.
Run mvn clean frequently to ensure that your project builds from a clean slate, removing any previously compiled files or dependencies that might cause issues.
Example: If you're encountering unexpected behavior after making changes to dependencies or code, running mvn clean install ensures that the build is fresh and free from any old artifacts that might affect the process.
These strategies help improve collaboration, simplify dependency management, and keep the project environment consistent and reproducible.
Also Read: Exploring the 14 Key Advantages of Java: Why It Remains a Developer's Top Choice in 2025
Next, let’s look at how upGrad can help you learn Java programming.
To effectively create a Maven project in Eclipse, start by organizing the project structure, clearly defining dependencies in the pom.xml, and properly configuring Maven plugins. This ensures that your project is scalable, maintainable, and easy to manage. Mastering these steps not only helps you create efficient projects but also enhances your employability as a skilled Java developer.
If you’re looking to build these skills and take your development career to the next level, upGrad can help. With their hands-on experience and expert guidance, you can master tools like Maven and Eclipse to build scalable applications.
In addition to the programs covered in the blog, here are some additional courses to complement your learning journey:
If you're unsure where to begin or which area to focus on, upGrad’s expert career counselors can guide you based on your goals. You can also visit a nearby upGrad offline center to explore course options, get hands-on experience, and speak directly with mentors!
Boost your career with our popular Software Engineering courses, offering hands-on training and expert guidance to turn you into a skilled software developer.
Master in-demand Software Development skills like coding, system design, DevOps, and agile methodologies to excel in today’s competitive tech industry.
Stay informed with our widely-read Software Development articles, covering everything from coding techniques to the latest advancements in software engineering.
References:
https://www.browserstack.com/guide/create-maven-project-in-eclipse
https://www.loginradius.com/blog/engineering/how-to-use-maven-dependency-in-eclipse
https://pg-p.ctme.caltech.edu/blog/coding/what-is-maven
https://arxiv.org/html/2504.07310v1
408 articles published
Software Engineering Manager @ upGrad. Passionate about building large scale web apps with delightful experiences. In pursuit of transforming engineers into leaders.
Get Free Consultation
By submitting, I accept the T&C and
Privacy Policy
India’s #1 Tech University
Executive PG Certification in AI-Powered Full Stack Development
77%
seats filled
Top Resources