Ubuntu 10.04 JDK Installation

Source: Internet
Author: User
1. Manually install JDK 6 first, download the jdk-6u12-linux-i586.bin here, it is said that this operation is relatively simple, do not need to switch. Then, you can place it in any folder you like and I will place it under the folder (/usr/lib/jvm/java. The command is as follows: Create a folder: www.linuxidc.com@linuxidc.com-laptop:/usr/lib/jvm/java $ s

1. Manually install JDK 6

First of all, download the jdk-6u12-linux-i586.bin here, it is said that this operation is relatively simple, do not need to switch.

Then, you can place it in any folder you like and I will place it under the folder (/usr/lib/jvm/java.

The command is as follows:

Create Folder: www.linuxidc.com@linuxidc.com-laptop:/usr/lib/jvm/java $ sudo mkdir-p/usr/lib/jvm/java

Copy the downloaded file to this directory: (the downloaded file is located in/home/linuxidc.com/downloads)
Www.linuxidc.com@linuxidc.com-laptop:/usr/lib/jvm/java $ sudo cp/home/linuxidc.com/Downloads/jdk-6u21-linux-i586.bin/usr/lib/jvm/java/

Go to the new directory: www.linuxidc.com@linuxidc.com-laptop:/usr/lib/jvm/java $ cd/usr/lib/jvm/java

View JDK installation directory and installation package permissions:

Www.linuxidc.com@linuxidc.com-laptop:/usr/lib/jvm/java $ ls-la
Total 81904
Drwxr-xr-x 3 root 4096.
Drwxr-xr-x 3 root 4096 ..
-Rwxrwxrwx 1 root 83854743 jdk-6u21-linux-i586.bin

If you do not have the preceding permissions, You need to modify the binfile permission to make it executable:

Www.linuxidc.com@linuxidc.com-laptop:/usr/lib/jvm/java $ sudo chmod 777 jdk-6u21-linux-i586.bin

Install jdk as follows:

Www.linuxidc.com@linuxidc.com-laptop:/usr/lib/jvm/java $ sudo-s./jdk-6u21-linux-i586.bin


After installation, configure the environment variables as follows:

Configure classpath and modify the environment variables of all users

Www.linuxidc.com@linuxidc.com-laptop:/usr/lib/jvm/java $ sudo gedit/etc/environment


Add at the end of the file:

PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
# Set java environment

JAVA_HOME =/usr/lib/jvm/java/jdk1.6.0 _ 21

Export JRE_HOME =/usr/lib/jvm/java/jdk1.6.0 _ 21/jre

Export CLASSPATH =.: $ JAVA_HOME/lib: $ JRE_HOME/lib: $ CLASSPATH

Export PATH = $ JAVA_HOME/bin: $ JRE_HOME/bin: $ PATH

PS: The above red part is configured based on the version you decompressed

(When I started Ubuntu again this morning, I found that I was unable to enter the desktop because I loaded the variable at startup and an error occurred. I entered another character in the JAVA variable, as a result, variables cannot be correctly identified, so the desktop cannot be accessed and the logon interface is stuck. The solution is as follows:

1: boot to the login interface, switch to the character interface: CTRL + ALT + F1 (or CTRL + ALT + F2....) to enter the character mode,

2: Log On As ROOT,

3: At this time, even the VI command cannot be identified. You need to modify and set the PATH first:

Export PATH = $ PATH:/usr/bin:/usr/sbin:/etc:/usr/sbin:/usr/bin/X11:/sbin

4: Edit vi/etc/environment to save the correct variables and exit.

5: reboot)

Because the default jdk in Ubuntu also needs to execute the following code, add the installed JDK to the java option:
Www.linuxidc.com@linuxidc.com-laptop: /usr/lib/jvm/java $ sudo update-alternatives -- install/usr/bin/java/usr/lib/jvm/java/jdk1.6.0 _ 21/bin/java 300

Update-alternatives: using/usr/lib/jvm/java/jdk1.6.0 _ 21/bin/java to provide/usr/bin/java (java) in auto mode.

Www.linuxidc.com@linuxidc.com-laptop: /usr/lib/jvm/java $ sudo update-alternatives -- install/usr/bin/javac/usr/lib/jvm/java/jdk1.6.0 _ 21/bin/javac 300

Update-alternatives: using/usr/lib/jvm/java/jdk1.6.0 _ 21/bin/javac to provide/usr/bin/javac (javac) in auto mode.

Then execute the default JDK code:
Sudo update-alternatives -- config java

Then execute the code in shell:
Www.linuxidc.com@linuxidc.com-laptop:/var $ java-version
Java version "1.6.0 _ 21"
Java (TM) SE Runtime Environment (build 1.6.0 _ 21-b06)
Java HotSpot (TM) Server VM (build 17.0-f8, mixed mode)

In this case, the java in the system is the java

To write a HelloUbuntu test:

Www.linuxidc.com@linuxidc.com-laptop:/var $ sudo gedit HelloUbuntu. java

Public class HelloUbuntu {
Public static void main (String [] args ){
System. out. println ("HELLO Ubuntu 10.04 LTS ");
}

}


Run the following JAVA command:

-Laptop www.linuxidc.com@linuxidc.com :~ $ Javac HelloUbuntu. java
-Laptop www.linuxidc.com@linuxidc.com :~ $ Java HelloUbuntu
------------------------------------------------
HELLO Ubuntu 10.04 LTS

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.