The process of installing JDK under Linux ubuntu14.04 __linux

Source: Internet
Author: User
Tags gz file mkdir
First go to the Oracle Web download JDK, I downloaded the jdk-8u51-linux-x64.tar.gz this version, the official web also has an RPM file, this is a Red Hat company installation version, I downloaded this version, and then in Ubuntu also installed rpm , but finally, when installing this RPM JDK, I encountered a lot of errors, which showed a row of errors. And then, on the official web, I downloaded the tar very decisively. GZ file. The installation was successful and the installation process was as follows
The jdk-8u51-linux-x64.tar.gz file we downloaded, by default, is downloaded from this folder in/home/ranruilong/, where Ranruilong is the directory of my username, and you can see our own installation directory in the home directory. Here you have to change your user directory.
Then unzip the compressed file and extract the command
sudo tar zxvf/jdk-8u51-linux-x64.tar.gz//here./Don't forget to write, represent the current directory
After decompression in the current directory, there is a jdk1.8.0_51
Enter LS in the terminal to see.
Typically, the JDK is installed into the/opt directory, and we move the uncompressed file above to/OPT/JAVA/JDK
In Terminal input command: cd/opt
New Java directory: mkdir Java
Entering the Java directory: CD java
New Jdk:mkdir JDK
After the folder is built, back to the start download directory
cd/home/ranruilong/Download
Input: MV JDK1.8.0_51/OPT/JAVA/JDK//So that the extracted files are moved to the JDK directory
Into the JDK can be queried, in the original download directory, you will find that the extract file has been moved by us.
The next step is to set the environment variable. Because we download the tar.gz compressed files, so directly after decompression, placed in the directory we want, and then set the environment variable, you can use the
Edit. bashrc file
In the terminal input: VI ~/.BASHRC Command, edit BASHRC file
Here is the operation of VI, very simple
In the terminal input: I (small i) to the BASHRC file for editing
At the end of the BASHRC, add the following variable
The directory of the JDK in export java_home=/opt/java/jdk1.8.0_51//Here is the directory of your own installation
Export Classpath=${java_home}/lib:. It must be + here. Path delimiter: The first time I didn't add, and then the main class was not found when I ran the Java file
Export Path=${java_home}/bin: $PATH
Then press the ESC key on the keyboard to return to command mode
Input: Wq Save the file we just modified
Finally, in the input source ~/.BASHRC. It's okay.
Now let's test if the installation is successful
In the terminal input java/javac/java-version, there will be some Java-related content, congratulations, the installation was successful.
Related Article

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.