Videos
Usually you install the openjdk like this:
sudo apt-get install openjdk-8-jdk
Maybe this is the problem. You can look this up at http://openjdk.java.net/install/index.html. If you do this you might have fixed this problem. But cant imagine why your command give this result.
I installed oracle-jdk8. If you need,
sudo add-apt-repository ppa:webupd8team/java && sudo apt update
sudo apt install oracle-java8-installer
You have just extracted the binary file but you didn't set JAVA_HOME.
First set the JAVA_HOME in your profile i.e. in ~/.bashrc file.
export JAVA_HOME=/usr/local/java/jdk1.8.0_45
export PATH=$PATH:$JAVA_HOME/bin
Reload the ~/.bashrc file as
> source ~/.bashrc press enter
Then try again.
> java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
The best way to do this is to use update alternatives not using JAVA_HOME. I downloaded the latest tarball jdk-8u162-linux-x64.tar.gz into a subdirectory ./src. I've also set up /opt so that it is owned by me, otherwise you need to use sudo for the untarring of the .tar.gz file.
#!/usr/bin/env bash
MAJOR_VERSION=8
ORACLE_BUILD_VERSION=162
JDK_TARBALL_VERSION=8u${ORACLE_BUILD_VERSION}-linux-x64
JDK_VERSION=1.${MAJOR_VERSION}.0_${ORACLE_BUILD_VERSION}
PRIORITY="10${MAJOR_VERSION}1"
cd src && tar xzf jdk-${JDK_TARBALL_VERSION}.tar.gz -C /opt/jdk
sudo update-alternatives --install /usr/bin/java java /opt/jdk/jdk${JDK_VERSION}/bin/java ${PRIORITY}
sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk${JDK_VERSION}/bin/javac ${PRIORITY}
echo "Checking: alternatives on java and javac"
sudo update-alternatives --display java
sudo update-alternatives --display javac
echo "Running: java -version"
java -version
I've included build 162 since this is much more recent that 45 in your message. This script above should be provided to everyone in the field of development since we can see currently that oracle-java8-installer for Debian and Ubuntu is broken as of yesterday. It might be fixed in a few days but this script will always work.
The priority value in the script is really important since you must override existing priority of the installed package. I've set it to use the major version to be installed. This priority would only fail if you have openjdk version 9 installed.
I'm on ChromeOS, using the dev environment. Linux penguin can't install java 8 jre. I tried and this happened:
sudo apt-get install openjdk-8-jre
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package openjdk-8-jre
pls help D: