This post describes how I install Java, Ant and Maven on my Windows PC, and how I setup the environment variables for development.

Install Java, Ant and Maven

When installing Java, Ant and Maven, I’m using C:\opt as basefolder, instead of the standard C:\Program Files (x86) directory.

Install Java, Multiple Versions

To install multiple java versions, I first uninstall any java installation from my PC, then i start installing the different versions, starting with the one with the lowest version number.

As install location, I’m used to change the default install directory, to have base path without spaces. As example:

C:\opt\java\x86\jdk1.6.0_45\
C:\opt\java\x86\jre6\

C:\opt\java\x86\jdk1.7.0_67\
C:\opt\java\x86\jre7\

C:\opt\java\x86\jdk1.8.0_40\
C:\opt\java\x86\jre1.8.0_40\

After installing Java I set the JAVA_HOME enviroment variable, and I add the java binaries entry ( %JAVA_HOME%\bin ) to the path.

JAVA_HOME=C:\opt\java\x86\jdk1.8.0_40
PATH=%JAVA_HOME%\bin;%PATH%;

To test it is working, I type from command prompt :

java -version

The result is below

 Install Ant

The installation consists in download the latest binary, and unpack the file into a directory in my PC. As example:

C:\opt\apache\ant-1.9.4

After unpacking I set the ANT_HOME environment variable and I add the %ANT_HOME%\bin entry to the path

ANT_HOME=C:\opt\apache\ant-1.9.4
PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%PATH%;

To test the setup, I type from command prompt:

ant -version

The result are below

Install Maven

As for Ant the installation consists in download the latest binary and unpack the file on a directory. As example:

C:\opt\apache\maven-3.2.5

Then I set Maven environment variables, and I add the maven binaries (%M2%) to the PATH.

M2_HOME=C:\opt\apache\maven-3.2.5
M2=%M2_HOME%\bin
MAVEN_OPTS=-Xms256m -Xmx512m
PATH=%PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin;%M2%;

To test it, I type from command prompt:

mvn --version

The result is below

Environment Variables

Supposing we installed java in C:\opt\java\x86\jdk1.8.0_40 ; we unpacked Ant in C:\opt\apache\ant-1.9.4 and Maven in C:\opt\apache\maven-3.2.5,  we should have set the below environment variables:

JAVA_HOME=C:\opt\java\x86\jdk1.8.0_40
ANT_HOME=C:\opt\apache\ant-1.9.4
M2_HOME=C:\opt\apache\maven-3.2.5
M2=%M2_HOME%\bin
MAVEN_OPTS=-Xms256m -Xmx512m
PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%M2%;%PATH%;

We can test the tools are working using command prompt, as follows:

java -version
ant -version
mvn --version

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *