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.