I\'ve been trying to install the jdk on my ubuntu after downloading it.
first I\'ve used: sudo apt-get update
then: sudo apt-get install jdk*
It's same as vikasdumca's steps, but thought to share the link.
run the following command
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
then
sudo apt-get install oracle-java8-installer
this would install oracle java 8 on ubuntu properly.
find it from this post
you can find more info on "Managing Java" or "Setting the "JAVA_HOME" environment variable" from the post.
In my case:
sudo -E add-apt-repository ppa:linuxuprising/java
sudo apt-get update
sudo apt install oracle-java12-installer
that works fine
Ubuntu defaults to the OpenJDK packages. If you want to install Oracle's JDK, then you need to visit their download page, and grab the package from there.
Once you've installed the Oracle JDK, you also need to update the following (system defaults will point to OpenJDK):
export JAVA_HOME=/my/path/to/oracle/jdk
export PATH=$JAVA_HOME/bin:$PATH
If you want the Oracle JDK to be the default for your system, you will need to remove the OpenJDK packages, and update your profile environment variables.
For me non of the above worked and I had to do as below, and it worked,
sudo -E add-apt-repository ppa:openjdk-r/ppa
and then,
sudo apt-get update
sudo apt-get install openjdk-8-jdk
Reference: https://askubuntu.com/questions/644188/updating-jdk-7-to-8-unable-to-locate-package
For those who had trouble with the apt-get, or with the long instruction. I solved it in a relatively painless way.
$ sudo dpkg -i oracle-java8-installer_8u51+8u51arm-1-webupd8-0_all.deb
Command Line option - Ubuntu
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
Then in terminal
sudo apt-get install oracle-java8-installer
When there are multiple Java installations on your System, the Java version to use as default can be chosen. To do this, execute the following command.
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws
Edit - Manual Java Installation
Download oracle jdk
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Extract zip into desired folder
e.g /usr/local/ after extract /usr/local/jdk1.8.0_65
Setup
sudo update-alternatives --install /usr/bin/java java /usr/local/jdk1.8.0_65/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/local/jdk1.8.0_65/bin/javac 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/local/jdk1.8.0_65/bin/javaws 1
sudo update-alternatives --set java /usr/local/jdk1.8.0_65/bin/java
sudo update-alternatives --set javac /usr/local/jdk1.8.0_65/bin/javac
sudo update-alternatives --set javaws /usr/local/jdk1.8.0_65/bin/javaws
Edit /etc/environment set JAVA_HOME path for external applications like Eclipse and Idea