Saturday, December 31, 2022

How to install Maven and Java JDK in windows and mac

  

How to install Maven and Java JDK in windows and mac

To install Apache Maven on Windows, you just need to download the Maven’s zip file, unzip it to a folder, and configure the Windows environment variables.

Tested with :

1.       JDK 10

2.       Maven 3.6

3.       Windows 10

Note

1.       Maven 3.3+ requires JDK 1.7+

2.       Maven 3.2 requires JDK 1.6+

3.       Maven 3.0/3.1 requires JDK 1.5+

1. JDK and JAVA_HOME

Make sure JDK is installed, and JAVA_HOME environment variable is configured. To download Open JDK go to

https://jdk.java.net/14/

Direct Download: https://download.java.net/java/GA/jdk14.0.2/205943a0976c4ed48cb16f1043c5c647/12/GPL/openjdk-14.0.2_windows-x64_bin.zip

Extract the zip file to a folder: Eg C:\Program Files\jdk-14.0.2

 

 

Next in the windows search Type Edit Enviroment Variables---

 

Enter Variable: JAVA_HOME  Value: your_file_path_to_java_folder

 


 

 

 

2. Download Apache Maven

2.1 Visit Maven official website, download the Maven zip file, for example : apache-maven-3.6.0-bin.zip.

 

2.2 Unzip it to any folder

Note
That’s all, just download and unzip, installation is NOT required.

3. Add MAVEN_HOME system variable

Add a MAVEN_HOME system variables, and point it to the Maven folder.

3.1 Press Windows key, type adva and clicks on the View advanced system settings

3.2 In System Properties dialog, select Advanced tab and clicks on the Environment Variables... button.

3.3 In “Environment variables” dialog, System variables, Clicks on the New... button and add a MAVEN_HOME variable and point it to c:\opt\apache-maven-3.6.0

 

4. Add %MAVEN_HOME%\bin To PATH

In system variables, find PATH, clicks on the Edit... button. In “Edit environment variable” dialog, clicks on the New button and add this %MAVEN_HOME%\bin

REPEAT SAME for %JAVA_HOME%\bin

 

 

5. Verification

Done, start a new command prompt, type mvn –version :

C:\Users\mkyong>mvn -version

Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)

Maven home: C:\opt\apache-maven-3.6.0\bin\..

Java version: 10.0.1, vendor: Oracle Corporation, runtime: C:\opt\Java\jdk-10

Default locale: en_MY, platform encoding: Cp1252

OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

 

C:\Users\mkyong>echo %MAVEN_HOME%

C:\opt\apache-maven-3.6.0

Copy

The Apache Maven is installed successfully on Windows.

6. FAQs

6.1 ‘mvn’ is not recognized as an internal or external command?

> mvn -version

'mvn' is not recognized as an internal or external command,

operable program or batch file.

Copy

Answer: Refer to Step 4, make sure the %MAVEN_HOME%\bin is added to the PATH system variable.

6.2 The JAVA_HOME environment variable is not defined correctly

> mvn -version

The JAVA_HOME environment variable is not defined correctly

This environment variable is needed to run this program

NB: JAVA_HOME should point to a JDK not a JRE

 Note: For MAC Users please use the below links

https://java.tutorials24x7.com/blog/how-to-install-openjdk-14-on-mac

https://javabydeveloper.com/how-to-install-maven-on-mac-osx/

No comments:

Post a Comment

Jenkins Scripted Pipeline - Create Jenkins Pipeline for Automating Builds, Code quality checks, Deployments to Tomcat - How to build, deploy WARs using Jenkins Pipeline - Build pipelines integrate with github, Sonarqube, Slack, JaCoCo, Nexus, Tomcat

  Jenkins Scripted Pipeline - Create Jenkins Pipeline for Automating Builds, Code quality checks, Deployments to Tomcat - How to build, depl...