Configure Sun JDK in ubuntu12.04

Source: Internet
Author: User
Tags gz file

5.1 At home, upgrade 10.10 to 12.04, because only one/partition was allocated during the previous partition, NO/home, so I am worried that everything in the home will be lost after I upgrade and install it with a USB flash drive, and I made a special backup. However, after the installation, we found that, as long as we choose to upgrade and install, instead of deleting the installation or manual partitioning, the original home is still there, and there will be two directories in the newly installed/home, one is the new user directory, the other is the previous user directory, but the system seems to only recognize the new user, it feels like installing two windows, the appearance of the oldwindows folder. So even if there is only one/partition, you don't have to worry about the files in the home when upgrading and installing.

Okay, I 've been talking nonsense for a long time. I haven't gotten to the point yet. Configure Sun's JDK. As for openjdk, go to the Software Center to search for it and install it. The following describes how to configure Sun's JDK.

1. Download from Oracle

I downloaded the jdk-7u4-linux-i586.tar.gz file and decompressed it directly.


2. Copy the extracted jdk1.7.0 _ 04 folder to the/usr/lib/JVM directory with the highest permissions.

$ Sudo CP-R ~ /Download/jdk1.7.0 _ 04/usr/lib/JVM


3. because I have installed openjdk in the Software Center before, the openjdk folder is already available in the/usr/lib/JVM directory, and the JDK version can be viewed using Java-version, openjdk is also reported. The following is to replace the default JDK of the system with the newly imported sunjdk.


4. Configure Environment Variables

Use gedit to open the hidden file. profile in the main directory

$ Gedit ~ /. Profile

Add export java_home =/usr/lib/JVM/jdk1.7.0 _ 04 at the end

Save and close, and use source to update

$ Source ~ /. Profile

Use the Env command to view the java_home Value

$ ENV

If java_home =/usr/lib/JVM/jdk1.7.0 _ 04, the configuration is successful.


5. Modify the default JDK of the system.

$ Sudo Update-alternatives -- install/usr/bin/Java/usr/lib/JVM/Java-7-sun/bin/Java 300

Just enter the number before Sun JDK.
$ Sudo Update-alternatives -- install/usr/bin/javac/usr/lib/JVM/Java-7-sun/bin/javac 300

$ Sudo Update-alternatives -- config Java
$ Sudo Update-alternatives -- config javac

Then enter Java-version. The following information indicates that the JDK is changed to sun.

Java version "1.7.0 _ 04"
Java (TM) se Runtime Environment (build 1.7.0 _ 04-b20)
Java hotspot (TM) server VM (build 23.0-b21, mixed mode)


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.