1. Go to Oracle website to download the Java7 SDK
Http://www.oracle.com/technetwork/java/javase/downloads/index.html
Here i download the latest java1.7.0_07
2. Unzip
Unzip the downloaded jdk-7u7-linux-i586.tar.gz and put it in the/USR/LIB/JVM folder. In general, there are no JVM folders under the/usr/lib folder and need to be created manually. The author uses the root Administrator account login (sudo passwd root), so it can be created directly under the Lib folder. If you are a non-root login, you can use the command:
mkdir /usr/lib//usr/lib/jvmmv xx/jdk-7u7-linux-i586.tar.gz. tar zxvf jdk-7u7-linux-i586.tar.gz
3. Modifying environment variables
In Terminal input:
Vim ~/.BASHRC
Vim command is not familiar with the Internet to find information, there are many
Then add the following code (I insert):
Export java_home=/usr/lib/jvm/java1.7.0_07
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Export Path=${java_home}/bin: $PATH
Save Exit (ESC +: Wq) and enter the following command to take effect immediately
SOURCE ~/.BASHRC
The Ps:/etc/profile setting method is valid for all logged-in users. ~/.BASHRC is valid only for the current user.
The above two is a configuration file, the system will read the/etc/profile, and then read ~/.BASHRC. Different user ~/.BASHRC files can have different settings,
/etc/profile is a shared one, and only root can modify it. ~/.BASHRC has an additional overlay effect on the/etc/profile.
4. Testing
Enter command Java-version If the result is as follows, the installation is correct.
[Email protected]:~# java-version
Java Version "1.7.0_07"
Java (TM) SE Runtime Environment (build 1.7.0_07-B10)
Java HotSpot (TM) Server VM (build 23.3-b01, Mixed mode
Ubuntu JAVA7 SDK environment variable configuration (RPM)