Installing default JRE/JDK
sudo apt-get update
sudo apt-get install Default-jre
sudo apt-get install DEFAULT-JDK
Installing Oracle JDK
sudo apt-get install python-software-properties
sudo add-apt-repository Ppa:webupd8team/java
sudo apt-get update
Oracle JDK 6 (older version)
sudo apt-get install Oracle-java6-installer
Oracle JDK 7 (newer stable version)
sudo apt-get install Oracle-java7-installer
Oracle JDK 8 (latest preview version)
sudo apt-get install Oracle-java8-installer
Managing Java
sudo update-alternatives--config Java has 2 candidates that can be used to replace Java (providing/usr/bin/java).
Select Path Priority state* 0/usr/lib/jvm/java-7-oracle/jre/bin/java 1072 Auto mode
1/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 Manual Mode
2/usr/lib/jvm/java-7-oracle/jre/bin/java 1072 Manual Mode
To maintain the current value [*], press ENTER, or type the number you selected:
(I pressed the carriage return, did not change)
sudo update-alternatives--config javac
Ibid.
Setting the "java_home" environment variable This command allows you to see the JAVA installation path:
sudo update-alternatives--config Java determines the path according to the option set, I am using the default first, so path is:
"/usr/lib/jvm/java-7-oracle"
sudo vim/etc/environment
At the end of the file add:
Java_home= "/usr/lib/jvm/java-7-oracle"
Save exit (: Wq), enter in Terminal:
source /etc/environment
Then enter:
Echo $JAVA _home
If the output is the same as our setup, it means that we have successfully installed it, and then you can look at the Java version:
java -version
Use Apt-get to install ORACLE-JDK on Ubuntu