There is also a method using multiple versions of Java by switching Java, such as method using jenv, but here the method using orthodox alternatives I'd like to introduce_______
For example, I think it will be useful in the following scenes, so it may be useful to remember just the command name alternatives.
alternatives are commands that come standard with CentOS.
If you look up alternatives with the man command, it says "maintain symbolic links determining default commands". It's hard to understand in English, but it's an excellent command that says, "You can use symbolic links to switch between software with similar functions and software with different versions."
In other words, it can be applied not only to Java but also to various commands **.
[[email protected] ~]# java -version
java version "12.0.1" 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
[[email protected] ~]# cd /usr/local/
[[email protected] local]# tar zxvf openjdk-12.0.1_linux-x64_bin.tar.gz
[[email protected] local]# ls | grep jdk
jdk-12.0.1
openjdk-12.0.1_linux-x64_bin.tar.gz
[[email protected] local]# alternatives --config java
There is one program'java'To provide.
Select command
-----------------------------------------------
*+ 1 /usr/java/jdk-12.0.1/bin/java
Press Enter to select the current[+]Or enter the selection number:
[[email protected] local]# alternatives --install /usr/bin/java java /usr/local/jdk-12.0.1/bin/java 2
[[email protected] local]# alternatives --config java
There are 2 programs'java'To provide.
Select command
-----------------------------------------------
*+ 1 /usr/java/jdk-12.0.1/bin/java
2 /usr/local/jdk-12.0.1/bin/java
Press Enter to select the current[+]Or enter the selection number:2
[[email protected] local]# alternatives --config java
There are 2 programs'java'To provide.
Select command
-----------------------------------------------
* 1 /usr/java/jdk-12.0.1/bin/java
+ 2 /usr/local/jdk-12.0.1/bin/java
Press Enter to select the current[+]Or enter the selection number:
[[email protected] local]# java -version
openjdk version "12.0.1" 2019-04-16
OpenJDK Runtime Environment (build 12.0.1+12)
OpenJDK 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
Recommended Posts