Install and configure Java JDK in Ubuntu 12.04

Source: Internet
Author: User

Download the jdkzip package from oracle. I downloaded the jdk-7u4-linux-i586.tar.gz file. Unzip the package

Step 1:
# Copy the extracted jdk1.7.0 _ 21 folder to the/usr/lib/JVM directory with the highest Permissions
Sudo CP-R ~ /Jdk1.7.0 _ 21 // usr/lib/JVM/

Step 2:
# Configure Environment Variables
Sudo gedit ~ /. Profile
Add:
Export java_home =/usr/lib/JVM/jdk1.7.0 _ 21

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 _ 21, the configuration is successful.

Step 3:
# Modify the system's default JDK
$ Sudo Update-alternatives -- install/usr/bin/Java/usr/lib/JVM/jdk1.7.0 _ 21/bin/Java 300

Just enter the number before Sun JDK.
$ Sudo Update-alternatives -- install/usr/bin/javac/usr/lib/JVM/jdk1.7.0 _ 21/bin/javac 300

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

Step 4:
Then enter Java-version. The following information is displayed, indicating 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)

 

Possible problems:
1. The error message "libjli. So cannot be started" is displayed ......, This problem occurs because the downloaded Java JDK package is incomplete or your decompression method is incorrect. Directly decompress the package to the current path and copy it to the desired directory, the JDK installation directory can be selected at will, for example, you can put it under the Home Directory,
The libjli. So file is in :~ /Jdk1.7.0 _ 07/JRE/lib/i386/jli/libjli. So

2. The configuration may fail. You need to uninstall the previously installed openjdk. You can run the command line to remove it.

3. for JDK of different versions, modify the version above.

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.