Detailed steps for configuring jdk in ubuntu

Source: Internet
Author: User
1. first download JDK from the JDK official website. it has been updated to JDK 7. select JavaPlatform (JDK) 7 ). Check your acceptlicenseagreement, then download the second jdk-7-linux-i586.tar.gz 2. after the download is complete, you need to download the file on your device...

 

1. first download JDK from the JDK official website. it has been updated to JDK 7. select the first JDK 7 ).

Check the above Accept License Agreement option, then download the second jdk-7-linux-i586.tar.gz

2. after the download is complete, you need to create a folder on your computer to install jdk

Take my example:

Jdk installed in/usr/java

Terminal: $ sudo mkdir/usr/java

Because the folder is created in usr, normal users do not have the permission, so sudo certainly you can su, but we do not recommend su

3. decompress the downloaded compressed file to your installation directory.

Download to/home/ghz/download by default.

Terminal: sudo tar zxvf/home/ghz/download-C/usr/java

OK. At this time, jdk has been decompressed from download to/usr/java.

4. rename

Go to/usr/java

Terminal: cd/usr/java

Terminal: sudo mv jdk1.7.0 java-7-sun

5. write and modify the configuration file:

Vim ~ /. Bashrc
Then add the following code:
Export JAVA_HOME =/usr/lib/jvm/java-7-sun
Export JRE_HOME =$ {JAVA_HOME}/jre
Export CLASSPATH =. :$ {JAVA_HOME}/lib :$ {JRE_HOME}/lib
Export PATH =$ {JAVA_HOME}/bin: $ PATH

Then: x or: wq is saved and exited.

Make it effective immediately: source ~ /. Bashrc

6. enter sudo update-alternatives -- install/usr/bin/java/usr/java-7-sun/bin/java 300 on the terminal.
Enter sudo update-alternatives -- install/usr/bin/javac/usr/java-7-sun/bin/javac 300 on the terminal
Enter sudo update-alternatives -- config java on the terminal

Select the jdk you just installed as the default jdk.

7. You can write a java file.

Compile it with javac and run it with java

8. jdk is successfully installed.

 

From: Lingfeng

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.