Detailed steps for installing jdk in linux: linuxjdk

Source: Internet
Author: User

Detailed steps for installing jdk in linux: linuxjdk

As a Java developer, installing some development tools in Linux is a required skill. This article takes jdk installation as an example and records the operation commands in each step for reference.

Method 1

You only need one command to install jdk:

Yuminstalljava-1.8.0-openjdk *-y

You can directly use

Method 2

0. Download jdk8

Select the jdk version to download. (After downloading files in Windows, share the files to Linux using folders)

1. log on to Linux and switch to the root user.

Su root obtains root user permissions, and the current working directory remains unchanged (the root password is required)

Or

Sudo-I directly switches to root without the root password (the current user password is required)

2. Create a java installation directory under 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. Decompress jdk to the current directory.

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

Get the jdk1.8.0 _ 60 folder.

5. After the installation is complete, create a link for him to save the directory Length

(I am not using this step)

Ln-s/usr/java/jdk1.8.0 _ 60 // usr/jdk

6. Edit the configuration file and configure the environment variables.

Vim/etc/profile

Add the following content: JAVA_HOME according to the actual directory

Export JAVA_HOME =/usr/java/jdk1.8.0 _ 60

Export CLASSPATH = $ JAVA_HOME/lib/

Export 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. view the installation status

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

This error may occur because a 64-bit jdk is installed on a 32-bit operating system,

Check whether the number of digits in jdk and Linux is the same.

Check whether your installed Ubuntu is a 32-bit or 64-bit system:

Sudo uname -- m

I686 // 32-bit

X86_64 // indicates 64-bit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.