Detailed steps to install JDK8 under Linux

1. Log in to Linux and switch to root user

su root to obtain root user authority, the current working directory remains unchanged (requires root password)
or
sudo -i does not require root password to switch directly to root (requires current user password)

2. Create a java installation directory in the usr directory

cd /usr

mkdir java

3. Copy jdk-8u60-linux-x64.tar.gz to the java directory

cp /mnt/hgfs/linux/jdk-8u60-linux-x64.tar.gz /usr/java/

4. Unzip the jdk to the current directory

tar -zxvf jdk-8u60-linux-x64.tar.gz

get the folder jdk1.8.0_60

5. After installation, create a link for him to save directory length

(I didn't use this step)
ln -s /usr/java/jdk1.8.0_60/ /usr/jdk

6. Edit the configuration file and configure environment variables

vim /etc/profile

add the following: JAVA_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 the installation

java -version

java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) Client VM (build 25.60-b23, mixed mode)

Possible error messages:

bash: ./java: cannot execute binary file

The reason for this error may be that a 64-bit jdk is installed on a 32-bit operating system.
Check whether the jdk version and the Linux version have the same number of digits.
Check whether the Ubuntu you installed is 32-bit or 64-bit system:
sudo uname --m
i686 //Indicates that it is 32-bit
x86_64 // Indicates that it is 64-bit

 

Transfer: http://www.cnblogs.com/shihaiming/p/5809553.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326485790&siteId=291194637