Install JDK and related configurations under Ubuntu

Source: Internet
Author: User
Tags echo command

1. View the number of system bits and enter the following command

Getconf Long_bit

2. Download the corresponding JDK file, which I downloaded here is jdk-8u60-linux-64.tar.gz

3. Create the directory as the JDK installation directory, where you select the installation location is:/usr/java/

sudo mkdir/usr/java

4. Unzip the file with the/usr/java/directory, the location of the file download is in the download directory

CD download
sudo tar zxvf jdk-8u60-linux-x64.tar.gz-c/usr/java/

5. Go to the/usr/java/directory and rename the folder (This step is not required, but it is recommended to configure the environment variables for convenience)

cd/usr/java/
sudo mv jdk1.8.0_60 jdk_8u60

6. Configuring System Environment variables

sudo gedit/etc/environment

Add the following red font content

Path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games: $JAVA _home/bin"
Export classpath=.: $JAVA _home/lib: $JAVA _home/jre/lib
Export java_home=/usr/java/jdk_8u60

Save and close after the modification is complete, and enter the following command to make the environment variable effective

Source/etc/environment

7. Use the echo command to check the configuration of environment variables

Echo $JAVA _home
Output/usr/java/jdk_8u60
Echo $CLASSPATH
Output.:/usr/java/jdk_8u60/lib:/usr/java/jdk_8u60/jre/lib
Echo $PATH
Output/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/java/jdk_8u60/bin

8. View the installation version:

Java-version
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

9. Set environment variables for all users, or the command cannot be found after reboot java

sudo gedit/etc/profile

Add the following (note the replacement path):

#set Java Environment

Java_home=/usr/java/jdk_8u60
Export JRE_HOME=/USR/JAVA/JDK_8U60/JRE
Export classpath=.: $JAVA _home/lib: $JRE _home/lib: $CLASSPATH
Export path= $JAVA _home/bin: $JRE _home/bin: $PATH

10. Restart the computer for the configuration to take effect.

11. Is it over? No!!!
If you are using an IDE such as MyEclipse, or if you have multiple JDK versions installed, continue looking down ↓↓↓

12. Modify the default JDK (note the replacement path)

sudo update-alternatives--install "/usr/bin/java" "java" "/usr/java/jdk_8u60/bin/java" 300
sudo update-alternatives--install "/usr/bin/javac" "Javac" "/usr/java/jdk_8u60/bin/javac" 300
sudo update-alternatives--install "/usr/bin/javaws" "Javaws" "/usr/java/jdk_8u60/bin/javaws" 300

The above is to establish a link for different commands, if there are multiple JDK only need to replace the path to re-execute the link, execute the following command to select the link, if each option only establishes a link, the system does not provide options, if there are multiple links, please select different options as required

sudo update-alternatives--config java
sudo update-alternatives--config javac
sudo update-alternatives--config javaws

End

CentOS Build JDK Environment http://www.linuxidc.com/Linux/2015-06/118879.htm

Ubuntu 14.04 installation jdk1.8.0_25 with configuration environment variables http://www.linuxidc.com/Linux/2015-01/112030.htm

Ubuntu 14.04 LTS installs Oracle JDK 1.8 http://www.linuxidc.com/Linux/2014-11/109216.htm

CentOS6.3 Installing the JDK and environment configuration http://www.linuxidc.com/Linux/2012-09/70780.htm

Ubuntu 14.04 Installation JDK8 http://www.linuxidc.com/Linux/2014-09/106218.htm

Ubuntu installation JDK graphic parsing http://www.linuxidc.com/Linux/2014-09/107291.htm

Install JDK and related configurations under Ubuntu

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.