In this post, you are going to learn.
a.
Download maven
b.
Setting up JAVA_HOME
c.
Setting up maven environment
d.
Verify maven installation
Download maven
Download maven from below location.
At the time of writing this article, 3.5.3 is the latest
version of the maven software.
Setting up maven in
your system
Extract the downloaded maven software.
Once you extract the downloaded zip, file, you can see
above kind of folder structure. All the maven executables will be located in
‘bin’ directory.
Since Maven 3.3+ require JDK 1.7 or above to execute, you
need to setup java run time environment in your system.
Following post can help you in setting up the java
environment.
Set JAVA_HOME environment variable to the base directory
of java installed location.
Setting up JAVA_HOME
Setting JAVA_HOME in windows
Right click on my computer -> properties.
Click on ‘Advanced system settings’.
Go to Advanced tab and click on ‘Environment Variables’
button.
In the System variables section, click on ‘New’ button.
Give the variable name as ‘JAVA_HOME’ and value to the
location (For ex: C:\Program Files (x86)\Java\jdk1.8.0_102), where java is
installed in your machine. Press Ok button.
That’s it you are done….:)
Setting JAVA_HOME in Linux
Environment
Korn and bash shells:
export JAVA_HOME=jdk-install-dir
Bourne shell:
JAVA_HOME=jdk-install-dir
export JAVA_HOME
C shell:
setenv JAVA_HOME jdk-install-dir
For example, in Windows, you can check whether JAVA_HOME
set or not, by executing below command.
C:\>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_102
You should append <JAVA_HOME>/bin path to the
system path.
Once everything is done, open command prompt (or)
terminal. Execute the command ‘javac -version’.
C:\>javac -version
javac 1.8.0_102
If you can see above kind of output, your java
installation is successful.
Setting up maven
environment
We need to set maven home (M2_HOME), M2 and maven options
(MAVEN_OPTS) environment variables.
In my case, I set the maven environment variables like
below.
M2_HOME=C:\Users\krishna\Documents\softwares\Maven\apache-maven-3.5.3
M2 = %M2_HOME%\bin
MAVEN_OPTS=-Xms256m -Xmx512m
Add maven bin directory path to the system path.
On Windows
Append the string ;%M2% to the end of the system
variable, Path.
On Linux environment
export PATH=$M2:$PATH
Verify maven
installation
Open command prompt (or) terminal and execute the command
‘mvn -version’.
If you are able to see below kind of output, then your maven
setup is correct.
C:\>mvn -version C:\ Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-25T01:19:05+05:30) Maven home: C:\Users\krishna\Documents\softwares\Maven\apache-maven-3.5.3 Java version: 1.8.0_102, vendor: Oracle Corporation Java home: C:\Program Files\Java\jdk1.8.0_102\jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Reference
No comments:
Post a Comment