Maven is a tool that can be used for building and managing any Java-based project. You can think of it as build manager. It allows a project to build using its project object model (POM) and a set of plugins that are shared by all projects using Maven, providing a uniform build system. In this blog post, we’ll discover steps required to install and configure Maven on windows server.
Install Java SDK on server and Configure environmental variables
This makes use of Chocolatey package manager. You need to have administrative privileges on the windows server in reference. First, make sure that execution policy to RemoteSigned. This should be standard on Windows Server 2012 R2 or higher. Else you can use Set-Execution policy for this:
Set-ExecutionPolicy RemoteSigned -Confirm:$false
To install Chocolatey, open a PowerShell prompt with administrative privileges, and run below command:
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
After this, we need to install JDK8 using below command:
choco install jdk8 -y
Chocolatey package will automatically create an environmental variable named JAVA_HOME and map it to appropriate path on the server. If you have installed Java manually, you need to add an variable named JAVA_HOME in environment variables and map it to appropriate installation location.
Install Maven and Configure environment variables
You can choose to visit Maven official website and download the required Maven zip file, ufor example : apache-maven-3.3.9-bin.zip. You then need it to unzip it to the folder you want to install Maven. Move unzipped files to this folder – C:\Program Files\Apache\Maven.
Alternatively, you can choose to install Maven from Chocolatey using this command:
choco install -y Maven
Again, if you have chosen to install Maven using Chocolatey, it will automatically create an environmental variables required.
If you have copied files manually, create two environmental variables named M2_HOME and MAVEN_HOME variables and point them to your Maven folder (This in our case would be C:\Program Files\Apache\Maven):
Once this is done, add %M2_HOME%\bin in the system PATH variable.
Verify Maven is working
For this, just run
on a command prompt. This should show an output like this:
One thought on “Install Maven on Windows Server”
your great man