Configure jdk1.6.0 _ 26 in Ubuntu11.04

Source: Internet
Author: User
1. Download jdk1.6.0 _ 26: JDK 1. Download jdk1.6.0 _ 26:

: Http://www.oracle.com/technetwork/java/javase/downloads/index.html

Download a jdk-6u26-linux-i586.bin version

2. installation:

Copy the jdk to the/usr/java directory. Install jdk in the/usr/java directory.

Go to the installation directory

cd /usr/java
sudo chmod 777 /usr/java/jdk-6u26-linux-i586.bin 
Then execute
sudo ./jdk-6u26-linux-i586.bin
3. Modify environment variables:
sudo vim /etc/profile
Add the following before the last sentence:
export JAVA_HOME=/usr/java/jdk1.6.0_26 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar 
Make environment variables take effect:
source /etc/profile

Now, JDK configuration is complete. You can check whether the following version is correct:
java -version 

The prompt is as follows:

Java version "1.6.0 _ 26"

Java (TM) SE Runtime Environment (build 1.6.0 _ 26-b03)

Java HotSpot (TM) Server VM (build between 1-b02, mixed mode)

4. test: the configuration is complete. You can write a simple java file to test it and create a new hello. java public class hello {public static void main (String args []) {System. out. println ("hello, this is my first java app ~ ");}}

Compile

Javac hello. java

Run

Java hello

The "hello, this is my first java app" string appears. Congratulations.

PS: If Ubuntu already has the default JDK, you only need to modify the default JDK and execute:

 
update-alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_26/bin/java 300 update-alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_26/bin/javac 300 
Next, select the default JDK:
update-alternatives --config java
Check whether the version is correct:
java -version

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.