Set up sun-JDK and maven2 in Ubuntu

Source: Internet
Author: User

Environment Description: Ubuntu server 12.04/Java-6-sun-1.6.0.06/apache-maven-3.0.4

1. Install sun-JDK

Because sun-JDK has been acquired by Oracle, UBUNTU supports open source. Currently, there is no update source for the new version of Oracle Java JDK. Therefore, to install sun-JDK, you must only install the old version, you must update the Ubuntu download source as follows:

Installation required

> Apt-Get install Python-software-Properties

Update the download source of the sun-6-jre to sources. List
> Add-Apt-repository "Deb http://us.archive.ubuntu.com/ubuntu/ hard Multiverse"

Then you can directly install the SDK through the command line. Before installation, you must update the apt-Get update list.

> Apt-Get install sun-java6-jdk

In general, UBUNTU server will install openjdk by default, so here we want to change the JDK priority and command link as follows:

> Update-alternatives -- install/usr/bin/Java/usr/lib/JVM/Java-6-sun-1.6.0.06/bin/Java 300

> Update-alternatives -- install/usr/bin/javac/usr/lib/JVM/Java-6-sun-1.6.0.06/bin/javac 300

Next, modify the default JDK.

> Sudo Update-alternatives -- config java. Select the default JDK as follows:

There are 3 choices for the alternative Java (providing/usr/bin/Java ).

Selection path priority status
------------------------------------------------------------
0/usr/lib/JVM/java-6-openjdk-amd64/JRE/bin/Java 1061 Auto Mode
1/usr/lib/JVM/java-6-openjdk-amd64/JRE/bin/Java 1061 manual mode
* 2/usr/lib/JVM/Java-6-sun-1.6.0.06/bin/Java 300 manual mode
3/usr/lib/JVM/Java-6-sun/JRE/bin/Java 63 manual mode

Press enter to keep the current choice [*], or type selection number: select 2 here.

So far, sun-JDK is installed on/usr/lib/JVM/Java-6-sun-1.6.0.06 by default.

 

2. Install maven2

To begin

Upload apache-maven-3.0.4-bin.tar.gz to the/usr/share directory and decompress the package using the following command:

> Tar-zxvf apache-maven-3.0.4-bin.tar.gz to/usr/share/apache-maven-3.0.4

Now Maven installation is complete

 

3. Configure Java and Maven Environment Variables

> VI/etc/environment

Path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: $ java_home/bin: $ maven_home/bin"
Java_home =/usr/lib/JVM/Java-6-sun-1.6.0.06
Classpath =.: $ java_home/lib
Maven_home =/usr/share/apache-maven-3.0.4
Export java_home
Export maven_home
Export classpath
Export path

The path: $ java_home/bin: $ maven_home/bin can be a single column or a single row.

Save the changes, and re-set the environment variables to take effect.

> Source/etc/environment

 

4. Check whether Java and Maven configurations are successful.

> JAVA-version
Java version "1.6.0 _ 06"
Java (TM) se Runtime Environment (build 1.6.0 _ 06-b02)
Java hotspot (TM) 64-bit server VM (build 10.0-b22, mixed mode)

> MVN-version
Apache Maven 3.0.4 (r1232337; 08:44:56 + 0000)
Maven home:/usr/share/apache-maven-3.0.4
Java version: 1.6.0 _ 06, vendor: Sun Microsystems Inc.
Java home:/usr/lib/JVM/Java-6-sun-1.6.0.06/JRE
Default locale: en_us, platform encoding: UTF-8
OS name: "Linux", version: "3.2.0-24-virtual", arch: "amd64", family: "Unix"

This indicates that the Java and Maven environment is successfully configured!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.