Maven Setup on Window/Linux

To setup Maven  on Window and Linux machine required below steps:

Step 1: Download latest version of maven from below link

Download Link : http://maven.apache.org/

Maven Configuration On Window

Unzip file apache-maven-X.X.X-bin.zip and change unzip file name like name as maven. It will have directory structure like below

window maven directory
Maven Directory Structure

Copy this maven folder to C:\Program Files (x86) directory.

Add below Environment Variable by right click on My Computer -> Properties-> Environment Variable/Advance System Settings

User Environment Variable
 
M2_HOME : C:\Program Files (x86)\maven
M2: %M2_HOME%\bin
PATH : %M2%;
 
If you already have any value in PATH add %M2%;   after end of value.

It will show as below in screen shot

Maven Path M2
  • Close all console instances/Command prompt if running and open new command prompt and run below command and will receive output with version of Maven and Java.
mvn –-version 
 
C:\Users\FacingIssuesOnIT>mvn --version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T11:41:47-05:00)
Maven home: C:\Program Files (x86)\maven
Java version: 1.8.0_73, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_73\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"

Maven Configure On Linux

Download latest version of Maven and Untar it with below command

tar -zxvf  apache-maven-3.5.0-bin.tar.gz

change name of directory as apache-maven-3.5.0 and set maven environment variable as below for configuration

$ export M2_HOME=/opt/app/facingissuesonit/apache-maven-3.5.0
 
$ export M2=$M2_HOME/bin
Set below for memory configuration
$ export MAVEN_OPTS=-Xms256m -Xmx512m
with M2_Home path corresponding with the location of your extracted Maven files.
 
Now append the M2 environment variable to the system path as below:
 
$ export PATH=$M2:$PATH

To check maven install successfully follow below command

mvn --version
 
Apache Maven 3.5.0 (r801777; 2009-08-06 15:16:01-0400)
Java version: 1.8.0_73
Java home: /opt/app/facingissuesonit/posbea/jdk-1.8.0_73/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-642.6.2.el6.x86_64" arch: "i386" Family: "unix"
 

Now your system is setup to develop any maven based application.

Happy Learning !!!

Java/JDK Setup On Windows and Linux with Eclipse

Before creating the Java project, the first thing is to check to JDK installed or not in your machine.

How to check Java version in your machine?

Window

  • Go to search
  • Type cmd and enter or search for Command prompt
  • You will see a black screen for the command prompt as below.
  • Type java -version to get detail about it.

Linux

  • On the current screen type command as java -version to get detail about it.
Check Java Version

The above screen is for the case when java is installed on your screen. If JDK/JRE is not installed on your machine then you will get a message like “Java is not recognized as an internal-external command.”

How to setup Java from Initial?

If JDK/JRE is not set up in your machine then follow below steps:

Download JDK from this siteDownload JDK Latest Version

Windows

  • After downloading click on the .exe file to install
  • Follow all steps as the next button and continue as long as a process not complete.
  • Default download location for Java will be  “C:\Program Files\Java\jdkVerXYZ”
Java/JDK Directory

To access Java from command prompts or IDE need to configure environment variables as JAVA_HOME and Path. The value of JAVA_HOME would be home directory path where JDK installed and Path would be (JAVA_HOME/bin)

Follow these steps to configure the environment variables

  • Go to Computer ->right click-> Properties -> Advance System Settings->System Variable
  • or Go to search type ENV and click on enter.
  • Enter that value of JAVA_HOME as below
Set JAVA_HOME
  • Set the Path by appending at last as below %JAVA_HOME%/bin;
  • Follow the above steps to check Java versions.

Linux 

  • Download JDK and untar it.
  • Go to your home directory/ sudo directory and set JAVA_HOME and Path in .bashrc file as below:

export JAVA_HOME=/opt/app/<installation directory>/jdk1.8.0_66

          export Path=%JAVA_HOME%/bin:$Path

  •   Save .bashrc file
  •  Now run java -version  to check configuration is successful.

Configure Eclipse IDE

Download Eclipse: Download Eclipse Latest Version

  • Click on the installable of Eclipse IDE.
  • Continue the installation by next click.
  • Select the path of JDK as installed.
  • Select the workspace location for your projects.

Now you are ready to create new projects in Eclipse IDE.

See Also :

Happy Learning !!!