Install the latest java JDK and linuxjdk on Linux
I have written an article on MC server (http://www.cnblogs.com/apollospotatolikett/p/6149042.html), the JDK used in the article is not the latest version, at that time did not elaborate on how to download and install the latest version, this time to elaborate.
Before starting the download and installation, let's make a few preparations:
Check whether java is installed and the version is displayed:
# java -version
You can use the preceding command to display that if no installation is found, you can use:
# sudo apt-get install default-jdk
Install the default version in the repository, but this version is not the latest. After installation, run the version check command to obtain
The figure shows that the version 1.7.0 _ 121 is installed, which is not what we want.
Then install the latest JDK:
Step 1 download the latest JDK installation package
First log on to the Java official website (http://www.oracle.com/technetwork/java/javase/downloads/index.html), click the button to enter the JDK download page, the figure shows that the latest version is 8u111/8u112.
The download page is as follows:
We will download the 8u111 version for demonstration. If there is a new version, the installation method is the same. When downloading the corresponding version, note that X86 refers to 32-bit machines and X64 refers to 64-bit machines.
There are two download methods:
1. Download commands
# axel http://202.117.4.101/cache/12/02/oracle.com/206932154def5188d39270dd88e56b07/jdk-8u111-linux-x64.tar.gz
You can use this command to download the file to the directory. If you have not installed axel, use:
# sudo apt-get install axel
Just install it.
2. Direct download
Of course, you can also download the package directly on the website and put it in the corresponding directory.
Step 2 install JDK
Find the corresponding Installation File jdk-8u111-linux-x64.tar.gz. Use:
# tar zxvf jdk-8u111-linux-x64.tar.gz
You can decompress the file to the current directory and get a jdk1.8.0 _ 111 folder.
Next, install the file into the system, and first create a directory (this command must be run by root, otherwise there will be permission issues)
# mkdir /usr/java
Move the Java file in (note that there is a space between jdk1.8.0 _ 111 and the Directory)
# mv jdk1.8.0_111 /usr/java
Finally, link to the system and enter the following command (note the space)
# update-alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_111/bin/java 1100
Run the following command to check whether the application is successful:
# java -version
Displayed as successful
Easy ~ Try it now!