Install JDK 7 in Ubuntu and configure the default JDK version (openjdk6 by default)

Source: Internet
Author: User

CD/usr/lib
Sudo mkdir JVM

Sudo tar zxvf jdk-7-linux-i586.tar.gz-C/usr/lib/JVM
CD/usr/lib/JVM
Sudo MV jdk1.7.0/Java-7-sun

Modify Environment Variables

Vim ~ /. Bashrc

Export java_home =/usr/lib/JVM/Java-7-sun
Export jre_home =$ {java_home}/JRE
Export classpath =. :$ {java_home}/lib :$ {jre_home}/lib
Export path =$ {java_home}/bin: $ path

Add $ path. Otherwise, the system path will be overwritten.

 

Source ~ /. Bashrc

 

Configure the default JDK version

Sudo Update-alternatives -- install/usr/bin/Java/usr/lib/JVM/Java-7-sun/bin/Java 300
Sudo Update-alternatives -- install/usr/bin/javac/usr/lib/JVM/Java-7-sun/bin/javac 300
Sudo Update-alternatives -- install/usr/bin/Jar/usr/lib/JVM/Java-7-sun/bin/jar 300

Sudo Update-alternatives -- config Java 

Enter 1, 2, and 3 to represent the default JDK version.

Java-version

Java version "1.7.0 _ 03"
Java (TM) se Runtime Environment (build 1.7.0 _ 03-b04)

Java hotspot (TM) server VM (build 22.1-b02, mixed mode)


If Java: cannot execute binary file appears, it is generally an operating system version.

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.