Configuring JDK environment variables under Ubuntu

Source: Internet
Author: User

To configure the JDK environment variable:

When you start the terminal and enter

    1. Gedit/etc/profile

Add the configuration at the end, save and exit

    1. #set JDK Environment
    2. Export java_home=/usr/lib/jvm/jdk1.7.0_21
    3. Export classpath=.:$JAVA _home/lib:$JAVA _home/jre/lib:$CLASSPATH
    4. Export path=$JAVA _home/bin:$JAVA _home/jre/bin:$PATH

Terminal input command to make configuration effective

    1. Source/etc/profile

4. See if the configuration is successful. In the terminal input

    1. Java-version

If the display version is 1.7.0.21, the configuration succeeds, as shown below:

    1. Java version "1.7.0_21"
    2. Java (TM) SE Runtime Environment (build 1.7.0_21-B11)
    3. Java HotSpot (TM) Server VM (build 23.21-b01, Mixed mode)

If the display is still OPENJDK, perform step 5, test again

5, configure default Jdk,ubuntu under Default JDK is OPENJDK. Terminal input

    1. sudo update-alternatives--install/usr/lib/java Java/usr/lib/jvm/jdk1.7.0_17/bin/java 300
    2. sudo update-alternatives--install/usr/lib/javac Javac/usr/lib/jvm/jdk1.7.0_17/bin/javac 300

Execute the following command to configure the default JDK

    1. sudo update-alternatives--config java

The JDK version is listed, which is labeled "*" as the default JDK. If you want to maintain the current default JDK, press ENTER directly, otherwise enter the number of the corresponding JDK to set it as the default version.

Configuring JDK environment variables 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.