Ubuntu replaces the Java environment with the installed version of OPENJDK as Oracle's JDK

Source: Internet
Author: User

    1. View the JDK version installed by the system

[email protected]: ~# java-version
Java Version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (7U79-2.5.5-0UBUNTU1)
OpenJDK 64-bit Server VM (build 24.79-b02, Mixed mode)

2. Upload the JDK to the/OPT directory

[email protected]: ~# cd/opt
[email protected]:/opt# ls
Jdk-6u45-linux-x64.bin

3. Modify the permissions of the JDK

[email protected]:/opt# chmod +x Jdk-6u45-linux-x64.bin

4. Execute the JDK file

[email protected]:/opt#./jdk-6u45-linux-x64.bin

5. Check out the extracted directory

[email protected]:/opt# ls
jdk1.6.0_45 Jdk-6u45-linux-x64.bin

6. Create a soft link

[email protected]:/opt# ln-s Jdk1.6.0_45/java
[email protected]:/opt# ls
Java jdk1.6.0_45

7. Modify the environment variable configuration file

[email protected]:/opt# vim/etc/profile

#set Java Environment
Export Java_home=/opt/java
Export Jre_home=/opt/java
Export classpath==.: $CLASSPATH: $JAVA _home/lib: $JRE _home/lib
Export path= $PATH: $JAVA _home/bin: $JRE _home/bin

8. Let the configuration file take effect

[email protected]:/opt# source/etc/profile

9. View the Java version

[email protected]: ~# java-version
Java Version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (7U79-2.5.5-0UBUNTU1)
OpenJDK 64-bit Server VM (build 24.79-b02, Mixed mode)

10. View the Java version of the new configuration

[email protected]: ~#/opt/java/bin/java-version
Java Version "1.6.0_45"
Java (TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot (TM) 64-bit Server VM (build 20.45-b01, Mixed mode)

11. Create a link

[email protected]: ~# update-alternatives--install/usr/bin/java Java/opt/java/bin/java 300
[email protected]: ~# update-alternatives--install/usr/bin/javac Javac/opt/java/bin/javac 300
Update-alternatives:using/opt/java/bin/javac to Provide/usr/bin/javac (javac) in Auto mode

12. Configure the system default Java environment

[email protected]: ~# update-alternatives--config java
There is 2 choices for the alternative Java (Providing/usr/bin/java).

Selection Path Priority Status
------------------------------------------------------------
* 0/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 Auto mode
1/opt/java/bin/java Manual Mode
2/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 Manual Mode

Press ENTER to keep the current choice[*], or type selection number:1

[email protected]: ~# update-alternatives--config Javac
There is a alternative in link Group Javac (providing/usr/bin/javac):/opt/java/bin/javac
Nothing to configure.

13. See if it takes effect

[email protected]: ~# java-version
Java Version "1.6.0_45"
Java (TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot (TM) 64-bit Server VM (build 20.45-b01, Mixed mode)

This article is from the "Cloud Life" blog, make sure to keep this source http://ovcer.blog.51cto.com/1145188/1652637

Ubuntu replaces the Java environment with the installed version of OPENJDK as Oracle's JDK

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.