Install JDK and set JDK environment variables in Ubuntu

Source: Internet
Author: User

 

Install jdk5.0 in Ubuntu

 

(Note: the latest version of ubuntu8.04 is installed with JDK by default, so you do not need to install it,

However, if you want to compile and run JavaProgramYou need to configure the environment variable and jump directly to step 2)

 

1. Install JDK, which significantly improves the performance of desktop programs.

 

(1) download jdk-1_5_0_10-linux-i586.bin from sun
(2) The default installation directory is/opt/jdk1.5.0 _ 10.
MV./jdk-1_5_0_10-linux-i586.bin/opt/(can also be copied directly to the/OPT directory with the mouse)
(3) sudo./jdk-1_5_0_10-linux-i586.bin for Installation
Or directly execute: Sh./jdk-1_5_0_10-linux-i586.bin select YES to install
(4) Configure classpath and modify the environment variables of all users
Sudo gedit/etc/profile
Add at the end of the file
 
# Set Java environment java_home =/opt/jdk1.5.0 _ 10
Export jre_home =/opt/jdk1.5.0 _ 10/JRE
Export classpath =.: $ java_home/lib: $ jre_home/lib: $ classpath
Export Path = $ java_home/bin: $ jre_home/bin: $ path
 
Save and exit.

(5) restart and run the command to test the JDK Java-version.
Java (TM) 2 Runtime Environment, Standard Edition (build 1.5.0 _ 10-b03)

Java hotspot (TM) Client VM (build 1.5.0 _ 10-b03, mixed mode, sharing)
The installation is successful.

You can also write a test class to test whether the environment variable settings are correct.

 

// Test. Java

Public class test {
Public static void main (string [] ARGs ){
System. Out. println ("test successfull! ");
}
}

 

(6) CD to your test. Java directory,
The following is my test result:

Benjamin @ Benjamin-desktop :~ $ Cd./javadev

Benjamin @ Benjamin-desktop :~ /Javadev $

Benjamin @ Benjamin-desktop :~ /Javadev $ javac test. Java

Benjamin @ Benjamin-desktop :~ /Javadev $ Java test Java

Test successfull!

Benjamin @ Benjamin-desktop :~ /Javadev $

The environment variables are correctly set.

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.