wiki:EclipseDevelopment/JavaMavenIntegration

Version 2 (modified by vegasm, 9 years ago) (diff)

--

In order to prepare Eclipse for Java Development, it is necessary to install JDK(Java Development Kit) in the system. Eclipse will use it to compile classes, provide an api and execute java apps. The installation also includes JRE (Java Runtime Environment) and JVM which executes compiled programmes.

1- How to download and install JDK

Choose your system and download the latest JDK Version from this url:

JDK: http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html

Linux installation requires some additional steps because Ubuntu repositories don't contain Oracle JDK.

tar -xvf jdk-7u3-linux-x64.tar.gz
sudo mkdir -p /usr/lib/jvm/jdk1.7.0
sudo mv jdk1.7.0_03/* /usr/lib/jvm/jdk1.7.0/
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
sudo update-alternatives --config java (Only if you have an old OpenJdk installation)

2- Configuration of Java Environment variables in our system (Windows and Linux)

PATH = C:\Program Files\Java\jdk1.7.0\bin (Necessary to exec javac command)
JAVA_HOME = C:\Program Files\Java\jdk1.7.0 (Necessary to be found by Eclipse)

3 - Download and configuration of Apache Maven

Download Apache Maven and unzip it where you want:

http://apache.rediris.es/maven/maven-3/3.0.4/binaries/apache-maven-3.0.4-bin.zip

Configure environment variables:

MAVEN_HOME = C:\Program Files\apache-maven-3.0.4
PATH = C:\Program Files\Java\jdk1.7.0\bin;%MAVEN_HOME%\bin; (Necessary to exec mvn command)

4- Check if your configuration is OK

Go to Start menu => execute => type cmd Type mvn-version and you should see something like this:

Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: C:\Program Files\apache-maven-3.0.4\bin\..
Java version: 1.7.0, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0\jre
Default locale: es_ES, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

5- Prepare Eclipse to use Maven (m2eclipse plugin)

Follow plugin installation process EclipseDevelopment and paste this url: http://download.eclipse.org/technology/m2e/releases