JAVA JDK version switching __java

Source: Internet
Author: User

First install sun1.6, here I install the directory is/usr/java/jdk1.6.0_45


Then set the profile file/etc/profile (add the file at the end of the file)

sudo vim/etc/profile

Export java_home=/usr/java/jdk1.6.0_45
export jre_home=/usr/java/jdk1.6.0_45/jre
export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
export path= $PATH: $JAVA _home/bin

Source/etc/profile

Then install openjdk1.7, you can install it in Software Center, and then execute the following command after installation:

gsc@gsc-250:~$ sudo update-alternatives--install/usr/bin/java java/usr/java/jdk1.6.0_45/bin/java
gsc@gsc-250:~$ sudo update-alternatives--install/usr/bin/javac javac/usr/java/jdk1.6.0_45/bin/javac
gsc@gsc-250:~$ sudo update-alternatives--install/usr/bin/javadoc javadoc/usr/java/jdk1.6.0_45/bin/javadoc
gsc@gsc-250:~$ sudo update-alternatives--install/usr/bin/javap javap/usr/java/jdk1.6.0_45/bin/javap 300

Switch using the following command:

gsc@gsc-250:~/my_carreer/webrtc-checkout$ sudo update-alternatives--config java 
There are 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            /usr/java/jdk1.6.0 _45/bin/java       Manual Mode
* 2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      Manual Mode

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

View current Java version:
<pre name= "code" class= "html ">gsc@gsc-250:~/my_carreer/webrtc-checkout$ java-version
java Version" 1.7.0_85 "
OpenJDK Runtime Environment (IcedTea 2.6.1) (7u85-2.6.1-5ubuntu0.14.04.1)
OpenJDK 64-bit Server VM (build 24.85-b03, Mixed mode)

The specific tools to switch are as follows:

2045  sudo update-alternatives--config java   
 2046  sudo update-alternatives  --config javac 2047 sudo update-alternatives--config javadoc
 2048  sudo update-alternatives--config javap

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.