Build JDK in Ubuntu

Source: Internet
Author: User

1. download the latest version of JDK, I downloaded from the http://www.oracle.com/technetwork/java/javase/downloads/index.html, the network speed is really slow here. I downloaded the: Java SE Development Kit 621jdk-6u21-linux-i586.bin file.

 

2. Extract

Open its folder under the command line and type chmod U + X./jdk-6u21-linux-i586.bin (Change executable permissions: U indicates the owner of the file, + indicates adding permissions, X indicates executable)
Then./jdk-6u21-linux-i586.bin
Then we can see that it is decompressed. After decompression, the default directory name is jdk1.6.0 _ 21.

 

3. Change the Directory

Sudo CP-r jdk1.6.0 _ 21/usr/(CP-R: recursive continuous replication, used for directory replication .)
Copy it to the USR directory.

 

4. Set environment variables:

Call VI ~ /. Bashrc (see http://yanxi.bokewu.com/blog93673.htm for the VI command
Http://hi.baidu.com/liaoxianyi/blog/item/d6d6d854d359fe5d574e002d.html)
Enter the user environment variable configuration interface and add the following three lines to the end. ESC,: WQ

Export java_home =/usr/jdk1.6.0 _ 21
Export classpath = $ classpath: $ java_home/lib: $ java_home/JRE/lib
Export Path = $ java_home/bin: $ java_home/JRE/bin: $ path: $ homr/bin

 

5. Test

We can write a simple helloworld program file like the following: helloworld. Java

// File name: helloworld. Java
Public class helloworld
{
Public static void main (string [] ARGs)
{
System. Out. println ("helloworld! ");
}
}

Run the following commands in the helloworld. Java directory:

Sudo/usr/jdk1.6.0 _ 21/bin/javac helloworld. Java

Java helloworld

 

References:

Build a Java environment
Http://www.cnblogs.com/ghj1976/archive/2010/04/14/1711895.html

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.