Switch JDK version under Ubuntu

Source: Internet
Author: User

Because Ubuntu will bring OPEN-JDK preinstalled in the system, when we need to install the JDK under Ubuntu, we found that even after the environment variables are configured, the input java-version version still does not change, we need the following 2 steps to switch/usr/local /java points to the JDK

##############################################

#第一步 We need to update the new version of the Java command to the system/usr/bin/301 is the priority

##############################################

sudo update-alternatives--install/usr/bin/java java/usr/local/jdk1.8.0_45/jre/bin/java 301

##############################################

#第二步 We reconfigure Java to select your newly installed JDK, after completing the java-version to see if the success

##############################################


[Email protected]:/usr/local$ sudo update-alternatives--config java

There are 2 candidates that can be used to replace Java (providing/usr/bin/java).
What we want.

Select Path Priority State
------------------------------------------------------------
0/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 Auto mode
* 1/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 Manual mode
2/usr/local/jdk1.8.0_45/jre/bin/java 301 Manual Mode



to maintain the current value [*] press ENTER, or type the number of your choice: 2
Update-alternatives:using/usr/local/jdk1.8.0_45/jre/bin/java to Provide/usr/bin/java (Java) in manual mode

[Email protected]:/usr/local$ java-version

Picked up _java_options:-dawt.usesystemaafontsettings=gasp

Java Version "1.8.0_45"

Java (TM) SE Runtime Environment (build 1.8.0_45-b14)

Java HotSpot (TM) 64-bit Server VM (build 25.45-b02, Mixed mode)



Switch JDK version under Ubuntu

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.