[Switch] - Linux use of handover alternatives version Jdk

1. Prepare JDK package, respectively, 1.7 and 1.8, jdk-7u79-linux-x64.tar.gz and jdk-8u161-linux-x64.gz;

2. decompression, after extracting the directory structure shown in FIG:

    JDK1.7:

 

    JDK1.8:

 

3. Then we need to specify for each version of their Java coding for selection when switching the Java version, note that this method because we do not need to configure the environment variables, so the specified number of times you need to specify the corresponding java execution file:

Use the command:

alternatives --install /usr/bin/java java /home/Java/jdk1.8.0_161/bin/java 180161

alternatives --install /usr/bin/java java /home/Java/jdk1.7.0_79/bin/java 170000

It should be noted that the lack of authority to remind that may arise in the implementation process, we need to give permission to the x java executable file, the command:

the X-/home/Java/jdk1.8.0_161/bin/java + chmod
chmod + the X-/home/Java/jdk1.7.0_79/bin/java
Finally, the command to switch the JDK version, switching commands:
        Alternatives --config the Java
appears the following dialogue:


The digits to the left and then select the corresponding version of our system given code is used, and will not switch when given encoding our
tests:

---------------------

Guess you like

Origin www.cnblogs.com/gwyy/p/10948481.html