1. Download the JDK
login URL: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Select the corresponding JDK version to download. (Can be shared to Linux via folder after download is completed under Windows)
2. Log in to Linux and switch to root
Su Root gets root user rights, the current working directory is unchanged (requires root password)
Or
Sudo-i does not require the root password to switch directly to root (requires the current user password)
3. Create a Java installation directory under USR
Entry to usr file: cd/usr
Build Java file: mkdir java
4. Copy the installation package to the Java directory (copy command in RZ for example)
Go to the Java file: Cd/usr/java
Execute command: RZ; Select the corresponding installation package for upload
5. Unzip the JDK to the current directory
TAR-ZXVF jdk-8u60-linux-x64.tar.gz
(Red for compressed package name)
Get folder jdk1.8.0_60
6. Configure Environment variables
Configure environment variables to be Add variable information to the Vim/etc/profile file, J Ava_home According to the actual directory:
Java_home=/usr/java/jdk1.8.0_60
Classpath= $JAVA _home/lib/
Path= $PATH: $JAVA _home/bin
Export PATH java_home CLASSPATH
7. Restart the machine or execute the command: Source/etc/profile
sudo shutdown-r now
8. Check if the JDK is installed successfully:
Java-version
Note:
An error message may appear:
BASH:./java:cannot Execute binary file
This error can occur because a 64-bit JDK is installed on a 32-bit operating system,
See if the JDK version and Linux version are the same number of bits.
To see if your Ubuntu installation is a 32-bit or 64-bit system:
sudo uname--m
i686//indicates 32-bit
x86_64//indicates 64-bit
Installing the JDK on a Linux server