Install and configure Java JDK in Ubuntu, and uninstall your own openjdk (Ubuntu 14.04 for example)

Source: Internet
Author: User
Tags ftp client

1. Download jdk-7u67-linux-x64.tar.gz

2. Upload the appropriate folder to Ubuntu using the FTP client tool FileZilla. If it is not possible to upload to the specified folder if the folder permissions are insufficient, modify the folder executable permission, the simplest way is to give permission, that is:

    1. chmod 777 Folder
    2. (777) for maximum privileges

3. Self-extracting installation JDK, I unzipped under the/usr/cpy

    1. TAR-XZVF jdk-7u67-linux-x64.tar.gz

The jdk1.7.0_67 folder is generated when the installation is complete

4. Setting environment variables, it is more convenient for users unfamiliar with VI to start a text editor with the gedit command than the VI command

    1. sudo gedit/etc/profile

Add the following and save the exit

Original content:

Path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

Newly added content:

Export Java_home= "/usr/cpy/jdk1.7.0_67"
Classpath= $CLASSPATH.: $JAVA _home/lib: $JAVA _home/jre/lib
Export path= $PATH: $JAVA _home/bin: $JAVA _home/jre/bin


Add $PATH to the front of the path=

Execute the following command to make the configuration effective

Source/etc/profile

Note: path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" must be retained, Doing so will cause the system not to log in. You can also use another two configurations instead of the line configuration:

5. How to unload your own OPENJDK:

    1. sudo apt-get remove openjdk*

6. Set the default JDK (if you have OpenJDK)

Because there may be default JDK in Ubuntu, such as OpenJDK. If there is a openjdk, so, in order to make the default use of the JDK we installed, also do the following ( you can use this command to install other commands, such as Eclipse).
Execute code:

    1. sudo update-alternatives--install/usr/bin/java Java/opt/jdk1.7.0_25/bin/java 300
    2. sudo update-alternatives--install/usr/bin/javac Javac/opt/jdk1.7.0_25/bin/javac 300

This step adds our installed JDK to the Java selection list.

Then execute the code:

    1. sudo update-alternatives--config java
    2. sudo update-alternatives--config javac

Use this step to select the system default JDK

7. View the Java version and display the JDK set for ourselves

[Email protected]$ java-version
Java Version "1.7.0_25"
Java (TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot (TM) Server VM (build 23.25-b01, Mixed mode)

Note: You can also use this method to configure a multi-JDK version, just modify the/etc/environment content and follow the steps below.

Install and configure Java JDK in Ubuntu, and uninstall your own openjdk (Ubuntu 14.04 for example)

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.