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