Unable install jdk8 in ubuntu 17.10

I used the following code to install jdk 8 and to add repository

sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update

After this when I try to install Java using the following command,

sudo apt-get install oracle-java8-installer

I am getting message, the code response is,

Reading package lists... Done
Building dependency tree      
Reading state information... Done
oracle-java8-installer is already the newest version (8u151-1~webupd8~0).
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.

Solution 1:

oracle-java8-installer is already the newest version

That's the error message that you get when you try to install the same package twice because the package is already installed. To prove it run the following command to show whether oracle-java8-installer is installed:

apt policy oracle-java8-installer  

When you tried to install oracle-java8-installer you got the following error message:

Download done.
Removing outdated cached downloads...
sha256sum mismatch jdk-8u151-linux-x64.tar.gz
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing: oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)

apt says that oracle-java8-installer is installed but java -version can't find java, so it must not have been installed correctly due to the sha256sum mismatch error which means that jdk-8u151-linux-x64.tar.gz was not downloaded correctly by the oracle-java8-installer script.

You might be having the same problem that others have that the oracle-java8-installer script isn't working properly: when i try to install or remove any softwares itis errer will occure please anyone help me so visit the official Oracle Java 9 website, download jdk-9.0.1_linux-x64_bin.tar.gz from there, and install it by following the instructions in this answer: How can I install Sun/Oracle's proprietary Java JDK 6/7/8 or JRE?.