Install java jdk environment on ubuntu

1: Download jdk-7u9-linux-i586.tar.gz and put it in the specified directory;

2: Open the terminal in this directory, and execute the following command. Create a new jdk decompression directory jvm under /usr/lib by executing the following command:

[ java] view plaincopy
sudo mkdir /usr/lib/jvm 
3: Extract the jdk file to the /usr/lib/jvm directory:

[java] view plaincopy
sudo tar zxvf jdk-7u9-linux-i586.tar.gz -C / usr/lib/jvm  
4: Set environment variables such as JAVA_HOME and CLASSPATH:

[java] view plaincopy
sudo gedit /etc/environment 
Add the following under the file:

[java] view plaincopy
PATH="/usr/lib/jvm/jdk1 .7.0_09/bin"  
JAVA_HOME="/usr/lib/jvm/jdk1.7.0_09" 
CLASSPATH=".:/usr/lib/jvm/jdk1.7.0_09/lib" 
5: If PATH already exists, use colon For interval, add the bin directory address of jdk, so that the java environment variable will be configured successfully, but the default JDK used may not be the one we just installed, because ubuntu may also have default jdk, such as openjdk; so , in order to use the jdk we installed by default, you need to execute the following command:

[java] view plaincopy
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_09/bin/java 300 
sudo update-alternatives --install /usr/bin/javac javac/ usr/lib/jvm/jdk1.7.0_09/bin/javac 300   
sudo update-alternatives --config java 
6: After the command is successfully executed, the JDK we installed is the system default, and you can see it successfully by executing the command java -version JDK related information such as:

[java] view plaincopy
java version "1.7.0_09" 
Java(TM) SE Runtime Environment (build 1.7.0_09-b05) 
Java HotSpot(TM) Client VM (build 23.5-b02, mixed mode) 

http://blog.csdn.net/scs2000/article/details/8546963

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326702159&siteId=291194637