Last week when installing the search engine Elasticsearch, asked to install a newer version of Java, I chose Java 1.8.0, the installation of Java after the successful use of java-version found that the version is still 1.6.0,
Some information was queried to find that the version of the selected software could be replaced with the Linux Alternatives command.
Description
Alternatives--install <link> <name> <path> <priority>
which
Install indicates installation
Link is a symbolic link
Name is the identifier
Path is the way to execute the file
Priority indicates precedence
A: First look at the current version of Java
II: Install Java 1.8.0 using the Linux Alternatives command
1. First use alternatives to see which Java versions are present in the system
Alternatives--config Java
2. Install Java 1.8.0 using the alternatives command
Alternatives--install/usr/bin/java Java/usr/local/java/jre1.8.0_131/bin/java 4
Explain:
/usr/bin/java is the path to the Java command, viewed with which Java, corresponding parameters <link>
Java corresponding parameters <name>
/usr/local/java/jre1.8.0_131/bin/java corresponds to <path>, the path of the Java command that represents java1.8.0
The number 4 corresponds to parameter <priority> because there are already 3 programs available in Java, so write 4
3. Use Alternatives--config Java to view the installation of Java 1.8.0 successfully
The red line of Java is what I just installed, indicating that the installation was successful
Three: Select Java version
Alternatives--config Java
See the results as in two (3), note the last sentence in English: Enter to keep the current selection[+], or type selection number, translate comes to press the ENTER key to save the currently selected [+], Or fade-in selection number. I typed the number 4 to indicate that I chose to use Java 1.8.0
Four: Use Java-version to view the selected version
Replace the version of the selected software with the Linux Alternatives command