First download Java se,:http://www.oracle.com/technetwork/java/javase/downloads/index.html;
After downloading the compressed package to the custom directory decompression can be (for example: In the/usr/lib/set up a Java directory, the compression package extracted into the directory);
There are two ways of configuring environment variables:
1, modify BASHRC:
sudo nano ~/.BASHRC
Then add the following code:
Export java_home=/usr/lib/java/jdk1.8.0_20/
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Export Path=${java_home}/bin: $PATH
2, Modify Environment:
sudo nano/etc/environment
Add the Bin directory of the JDK after the existing path variable, and note that the colon is separated from the existing variable
Add Calsspath and Java_home variables again
My situation is as follows:
Path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/java/ Jdk1.8.0_20/bin "
Classpath= "/usr/lib/java/jdk1.8.0_20/lib:." Notice there's a point in the back.
Java_home= "/usr/lib/java/jdk1.8.0_20/"
After modifying the configuration, log off or restart to make the environment variable effective!
See if it takes effect, terminal execution: java-version, you can see the version.
Ubuntu 14.04 Configuration Java SE