View All
View All
View All
View All
View All
View All
View All
View All
View All
View All
View All

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:

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.

Ready to learn Maven and other essential development tools? Join upGrad’s Online Software Development Courses to enhance your skills in Java, project management, and software development practices with hands-on projects and expert guidance.

How to Create Maven Project in Eclipse? A Step-by-Step Guide

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:

Step 1: Install Maven in Eclipse

Before creating a Maven project in Eclipse, ensure that Maven is installed and configured in Eclipse. Here’s how to do it:

  • Open Eclipse, go to Help > Eclipse Marketplace.
  • Search for Maven and install the Maven Integration for Eclipse (M2Eclipse) plugin.
  • Restart Eclipse to complete the installation.

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

Step 2: Create a New Maven Project in Eclipse

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:

  • Open Eclipse and go to File > New > Other.
  • In the New Project dialog, type Maven and select Maven Project. Click Next.
  • On the next screen, select Create a simple project and click Next.

Now, you'll specify the Group Id and Artifact Id:

  • Group Id: This represents your organization or group. For example, com.mycompany.
  • Artifact Id: This represents the project name. For example, my-app.

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] 

Step 3: Understand the Maven Project Structure

Now, you'll explore the Maven project structure, including the pom.xml file for configuration, and the src directories for source code and tests.

  • pom.xml: The Project Object Model (POM) file contains project configuration details such as dependencies, plugins, and project information.
  • src/main/java: This is where your main application code resides. It contains the source code for your project, organized by package.
  • src/test/java: This folder contains the test classes, usually for unit tests using frameworks like JUnit.

Coverage of AWS, Microsoft Azure and GCP services

Certification8 Months

Job-Linked Program

Bootcamp36 Weeks

You can also get a hang of JavaScript from upGrad’s free JavaScript Basics from Scratch course. It covers variables, data types, loops, functions, and event handling. Build interactive web applications and gain the skills to create websites from scratch.

Also Read: Learn 50 Java Projects With Source Code (2025 Edition)

Step 4: Understanding the Code

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'

If you want to build a higher-level understanding of Javascript, upGrad’s Advanced Javascript for All course is what you need. Learn about prototypes, scopes, classes, modules, async programming, and more to enhance your web development skills and become a proficient JS developer.

Also Read: IntelliJ IDEA vs. Eclipse: The Holy War!

Step 5: Building and Running the Maven Project in Eclipse

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.

  • Right-click on the project in the Project Explorer.
  • Select Run As > Maven build.
  • In the Goals field, type clean install and click Run.

This command will clean the project, install dependencies, and package it.

2. Run the Project: To run the project:

  • Right-click on the App.java file.
  • Select Run As > Java Application.
  • The output should display:
Hello, Maven!

Also Read: How To Create Spring Boot Project In Eclipse

Step 6: Adding Dependencies to pom.xml

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

What is POM in Maven? A Simple Explanation

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?

  • Dependencies: Maven will download JUnit 4.12 during the test phase for running unit tests. You can use JUnit annotations like @Test in your project to write test cases.
  • Compiler Settings: The project will be compiled with Java 1.7, as specified in the <properties> section.
  • Build: Running mvn clean install will clean the previous build and install the project, compiling the source code using Java 1.7 and adding the JUnit dependency for testing purposes.

Output Explanation for Maven Build:

When you run the following command in the terminal:

mvn clean install

Here’s what you can expect:

  1. Clean: It will clean up any previously compiled code.
  2. Compile: It will compile the source code (src/main/java) using Java 1.7 as specified in the POM.
  3. Test: It will run any unit tests (using JUnit, as specified in the dependencies section).
  4. Install: Finally, it will install the project in your local repository, making it available for other projects to use as a dependency if needed.

Here is a simple run-through of essential POM elements:

  • project: The highest element in every pom.xml file
  • groupId: The identifier of the project’s creator group. It is always unique and is one of the most critical identifiers of a project. 
  • url: It shows the location (the site) of the project. 
  • modelVersion: It shows the version of the object model the current POM is employing. While the object model’s version doesn’t change often, it’s crucial for keeping the project stable.
  • build: It performs tasks related to the management of plugins, declaring the directory structure, etc. 
  • version: It shows the artifact’s version your project has generated. Version management is quite tricky, and Apache Maven helps you substantially with that. 

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.

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:

1. Simplified Dependency Management

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.

2. Consistent Build Process

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.

3. Easy Integration with Continuous Integration (CI) Tools

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.

4. Project Structure Standardization

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.

5. Enhanced Code Management and Version Control

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.

6. Built-in Testing and Reporting Tools

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.

Best Practices for 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:

1. Use a Consistent Directory Structure

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.

2. Define Clear Versioning in pom.xml

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.

3. Use Profiles for Environment-Specific Configuration

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.

4. Leverage Dependency Management

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.

5. Use the clean Goal Regularly

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.

How Can upGrad 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

Frequently Asked Questions (FAQs)

1. Why does my Maven project show compilation errors in Eclipse even though it builds successfully from command line?

2. How can I configure Eclipse to automatically import Maven dependencies when I add them to pom.xml?

3. Why does Eclipse show "Plugin execution not covered by lifecycle configuration" errors for certain Maven plugins?

4. How do I resolve Maven dependency conflicts that only appear in Eclipse but not in command line builds?

5. Why does my Maven project's source folders (src/main/java, src/test/java) not appear correctly in Eclipse Package Explorer?

6. How can I debug Maven plugin executions directly from Eclipse during the build process?

7. Why does Eclipse show different test results than running mvn test from command line?

8. How do I handle Maven multi-module projects in Eclipse when some modules have circular dependencies or complex interdependencies?

9. Why does Eclipse's Maven integration sometimes fail to resolve SNAPSHOT dependencies from remote repositories?

10. How can I configure Eclipse to use a different Maven installation than the embedded one for better compatibility?

11. Why do my Maven-generated sources (like from protobuf or JAXB plugins) not appear in Eclipse's source path automatically?

12. How do I troubleshoot when Eclipse shows "Project configuration is not up-to-date with pom.xml" warnings persistently?

Rohan Vats

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

+91

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

View Program

Top Resources

Recommended Programs

upGrad

AWS | upGrad KnowledgeHut

AWS Certified Solutions Architect - Associate Training (SAA-C03)

69 Cloud Lab Simulations

Certification

32-Hr Training by Dustin Brimberry

upGrad KnowledgeHut

upGrad KnowledgeHut

Angular Training

Hone Skills with Live Projects

Certification

13+ Hrs Instructor-Led Sessions

upGrad

upGrad

AI-Driven Full-Stack Development

Job-Linked Program

Bootcamp

36 Weeks