DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Using Lombok Library With JDK 23
  • A Maven Story
  • Alternative Structured Concurrency
  • OpenAPI From Code With Spring and Java: A Recipe for Your CI

Trending

  • 5 Layers of Prompt Injection Defense You Can Wire Into Any Node.js App
  • LLM Integration in Enterprise Applications: A Practical Guide
  • Building AI-Powered Java Applications With Jakarta EE and LangChain4j
  • Getting Started With Agentic Workflows in Java and Quarkus
  1. DZone
  2. Coding
  3. Java
  4. How To Download and Install Maven?

How To Download and Install Maven?

Learn how to download, install and set up Maven quickly and easily on Windows to manage dependencies and build Java projects efficiently.

By 
Pallavi Singh user avatar
Pallavi Singh
·
Jul. 24, 23 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
5.0K Views

Join the DZone community and get the full member experience.

Join For Free

The Apache Group created the well-liked open-source build tool Maven to build, publish, and deploy multiple projects simultaneously for improved project management. The lifecycle framework can be built and documented using the provided tool. 

Maven is built in Java and is used to create projects in C#, Scala, Ruby, and other languages. This tool, which is based on the Project Object Model (POM), has made the life of Java developers simpler when producing reports, checking builds, and testing automated settings. 

The Objective of Maven

The goal of Maven is to enable developers with: 

  • A project model that is comprehensive, maintainable, reusable, and easy. 
  • A collection of tools and plug-ins for interacting with the declarative model. 

Feature Of Java: 

Maven has plenty of essential and useful characteristics, which helps to explain why it is attractive. Here are some of Maven’s most notable features:

  • A vast, constantly increasing archive of user libraries 
  • The ability to simply build up projects making use of best practices 
  • Management of dependencies with automated update 
  • Compatibility with prior versions.
  • Reporting with high accuracy and honesty
  • Uniform use across all projects

Install Maven on Windows

First, we need to install JDK (Java development kit) on our PC, followed by Maven on Windows. 

In Order to download Java. Land Download page on that page, you may locate the JDK for many platforms and operating systems.
JDK download

While Java is being installed, let’s get started on installing Maven on Windows: 

  • Navigate to Browser 
  • Enter Maven Download and navigate to apache maven download
maven download
  • Use the Apache zip archive link to download. 
  • After downloading both JDK and Apache Maven, we’ll navigate to the directory containing the Java executables. 
  • Install the whole JDK.
  • Immediately after the installation of the JDK, we must navigate to the Maven directory and extract the files. 
  • After Downloading Java and Maven we need to set its path into system properties 
  • In Order to set Path search for Environment Variable in your PC and open it. 

set Path search for Environment Variable

  • After then go to the Java bin path in your local directory and set Java Path

Java bin path

Java bin path

  • Now Open CMD and type the command java –version.

CMD

  • After that Set New Environment Variable for Maven 
  • Open Environment Variable in the same way described above and under the system, variable enter Maven Home.

Open Environment Variable

  • Now set the M2 variable for Maven again.

set the M2 variable for Maven

  • Then Edit the path and set Maven Bin Path

Edit the path and set Maven Bin Path

  • Now click OK. 
  • Maven has been installed. Return to the command prompt window to confirm that Maven is installed. 
  • Open CMD and enter the MVN version

Open CMD and enter the MVN version

  • We can see that JDK and Maven are both installed on our machine. 

Install Maven on Ubuntu

  • Launch the terminal. 
  • To install packages, use the root id. 
  • After completing the preceding steps, execute the app update command. 
  • Install the most recent Java package next. 

While Java is being installed, let’s get started on installing Maven: 

  • Navigate to Browser 
  • Enter Maven Download and navigate to apache maven download 
  • Navigate to the Binary tar.gz archive.

  • Copy the Binary tar.gz archive link. 
  • Once the Java installation is complete, use a new terminal to install Maven. 
  • Navigate to the opt directory by entering the command i.e. “cd /opt” 
  • Then execute the wget command along with the link copied above i.e.” wget *link of tar.gz archive*” 
  • After downloading the Maven tar file, extract it. 
  • We can see the Apache Maven directory when the extraction is complete. 
  • Let’s go to the Maven directory now by entering the command i.e. “cd maven/” 
  • Return to terminal 1 and check the Java version by entering the command i.e. “java -version” 
  • Navigate back to terminal 2 and enter the command i.e. “cd/ etc/ profile.d/” 
  • All of the path variables are visible here. 
  • To add more options, use the echo command to copy the path variables by entering the command i.e.” echo *path copied* /opt/maven/bin >>maven.sh” 
  • Now, export MVN_HOME to this directory by entering the command i.e.” echo “export MVN HOME=/opt/maven” >>maven.sh” 
  • Finally, we’ll grant this file executable permissions by entering the command i.e.” source /etc/profile.d/maven.sh” 
  • Following this, we can execute the Maven version command i.e. “MVN-version”

Conclusion

After completing these steps, you should have a working copy of Maven on your Windows machine as well as on Ubuntu.

Apache Maven Download Java Development Kit Java Database Connectivity cmd

Published at DZone with permission of Pallavi Singh. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Using Lombok Library With JDK 23
  • A Maven Story
  • Alternative Structured Concurrency
  • OpenAPI From Code With Spring and Java: A Recipe for Your CI

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook