Debain 8 apt-get "E: The package jre1.8.0-45 needs to be reinstalled"

root@localhost:~# sudo apt-get purge openjdk-7-*
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package jre1.8.0-45 needs to be reinstalled, but I can't find an archive for it.
root@localhost:~# java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)
root@localhost:~#

This might be an issue. lol.

You still have Java installed :)

I haven't used Debian with java for a while as I mainly use Gentoo but you may have a config issue with the /var/lib/dpkg/info/ which might explain the error. If this is the case, you could remove all entries of version 1.8.0.45 or if there are actual files present in /var/lib/dpkg/info/jdk1.8.0-45 like a prerm/postrm script you could change the -e errexit code or try rebuilding jdk1.8.0.45 from source.

I would still remove all versions of Java installed - ie; java version "1.8.0_51"

Check what you're removing.

dpkg --get-selections | awk '/oracle-java/ && /installer/ {print "sudo apt-get purge "$1}' 
dpkg --get-selections | awk '/openjdk/ {print "sudo apt-get purge "$1}'

Remove;

dpkg --get-selections | awk '/oracle-java/ && /installer/ {system("sudo apt-get purge "$1)}'
dpkg --get-selections | awk '/openjdk/ {system("sudo apt-get purge "$1)}'

Good luck.

I decided come back to this a few days later since I haven't had the time recently.

I don't know if java is still installed or not

root@localhost:/var/lib/dpkg/info# java -version
-su: /usr/bin/java: No such file or directory
root@localhost:/var/lib/dpkg/info# update-alternatives --config java
update-alternatives: error: no alternatives for java
root@localhost:/var/lib/dpkg/info#

unfortunately when I tried the commands that you suggested, I only got a return for opened, but due to the same issue, I cannot remove it.

root@localhost:/var/lib/dpkg/info# dpkg --get-selections | awk '/oracle-java/ && /installer/ {print "sudo apt-get purge "$1}'
root@localhost:/var/lib/dpkg/info# dpkg --get-selections | awk '/openjdk/ {print "sudo apt-get purge "$1}'
sudo apt-get purge openjdk-7-jdk:amd64
sudo apt-get purge openjdk-7-jre:amd64
sudo apt-get purge openjdk-7-jre-headless:amd64
root@localhost:/var/lib/dpkg/info# dpkg --get-selections | awk '/oracle-java/ && /installer/ {system("sudo apt-get purge "$1)}'
root@localhost:/var/lib/dpkg/info# dpkg --get-selections | awk '/openjdk/ {system("sudo apt-get purge "$1)}'
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package jre1.8.0-45 needs to be reinstalled, but I can't find an archive for it.
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package jre1.8.0-45 needs to be reinstalled, but I can't find an archive for it.
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package jre1.8.0-45 needs to be reinstalled, but I can't find an archive for it.
root@localhost:/var/lib/dpkg/info#

You could try this alternate solution maybe:

unfortunately I am still unable to install software using apt-get

michael@localhost:/var/lib/dpkg/info$ sudo apt-get install oracle-java8-installer
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package jre1.8.0-45 needs to be reinstalled, but I can't find an archive for it.
michael@localhost:/var/lib/dpkg/info$

You have more patience than I, I'd have reinstalled.

How did you install Java before? Was it through the package manager or did you download a .deb?

From @epsilont link did you try both solutions?

I see, manual removal didn't help then.

I would download jre1.8.0-45 from here.

Extract the jre1.8.0-45 archive into your /opt directory and create a new path and symbolic link for jre1.8.0-45.

update-alternatives --install /usr/bin/java java /opt/jre1.8.0_45/bin/java 1

Change the java version to jre1.8.0-45;

update-alternatives --config java

Then check if the java version in use is jre1.8.0-45

java -version

i've reinstalled java to the system, but i'm still unable to use apt-get or assumably any other functions that were inhibited by the issue.

michael@localhost:~/Downloads$ ls jre*
jre1.8.0-45_1.8.045-1_amd64.deb jre-8u45-linux-x64.tar.gz
jre-8u45-linux-x641.rpm jre-8u51-linux-x64 (1).tar.gz
jre-8u45-linux-x64 (1).tar.gz jre-8u51-linux-x64.tar.gz
michael@localhost:~/Downloads$ cp jre
jre1.8.0-45_1.8.045-1_amd64.deb jre-8u45-linux-x64.tar.gz
jre-8u45-linux-x641.rpm jre-8u51-linux-x64 (1).tar.gz
jre-8u45-linux-x64 (1).tar.gz jre-8u51-linux-x64.tar.gz
michael@localhost:~/Downloads$ cp jre-8u45-linux-x64 (1).tar.gz
bash: syntax error near unexpected token ('
michael@localhost:~/Downloads$ cp jre-8u45-linux-x64 (1).tar.gz /opt/
bash: syntax error near unexpected token
('
michael@localhost:~/Downloads$ cp "jre-8u45-linux-x64 (1).tar.gz" /opt/
cp: cannot create regular file ‘/opt/jre-8u45-linux-x64 (1).tar.gz’: Permission denied
michael@localhost:~/Downloads$ sudo cp "jre-8u45-linux-x64 (1).tar.gz" /opt/
[sudo] password for michael:
michael@localhost:~/Downloads$ cd /opt
michael@localhost:/opt$ ls
firefox google jre-8u45-linux-x64 (1).tar.gz spotify wine-staging
michael@localhost:/opt$ tar -xzf jre-8u45-linux-x64\ (1).tar.gz
tar (child): jre-8u45-linux-x64 (1).tar.gz: Cannot open: Permission denied
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
michael@localhost:/opt$ sudo tar -xzf jre-8u45-linux-x64\ (1).tar.gz
michael@localhost:/opt$ ls
firefox jre1.8.0_45 spotify
google jre-8u45-linux-x64 (1).tar.gz wine-staging
michael@localhost:/opt$ update-alternatives --install /usr/bin/java java /opt/jre1.8.0_45/bin/java 1
update-alternatives: using /opt/jre1.8.0_45/bin/java to provide /usr/bin/java (java) in auto mode
update-alternatives: error: error creating symbolic link '/etc/alternatives/java.dpkg-tmp': Permission denied
michael@localhost:/opt$ sudo update-alternatives --install /usr/bin/java java /opt/jre1.8.0_45/bin/java 1
update-alternatives: using /opt/jre1.8.0_45/bin/java to provide /usr/bin/java (java) in auto mode
michael@localhost:/opt$ update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /opt/jre1.8.0_45/bin/java
Nothing to configure.
michael@localhost:/opt$ 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)

iv'e also noticed that when running the following command, entries for openjdk are still returned. is/could this be a problem?

michael@localhost:~$ dpkg --get-selections | awk '/openjdk/ {print "sudo apt-get purge "$1}'
sudo apt-get purge openjdk-7-jdk:amd64
sudo apt-get purge openjdk-7-jre:amd64
sudo apt-get purge openjdk-7-jre-headless:amd64
michael@localhost:~$

@Eden
I believe that I can learn more about linux by solving any reasonable problem at hand, than by reinstalling the entire operating system. :)

I endes up solving my problem today uaing the infoemation supplyed on this page.

askubuntu.com/questions/602276/the-package-jre1-8-0-40-needs-to-be-reinstalled-but-i-cant-find-an-archive-for

From what i read in the file, the problem was caused by converting and installing a .rpm version of java using alien.

Thank you too all those who have provided assistance in this matter.

Interesting issue, glad you solved it.

I should have explained how to do this; as I tend to expect an assumed knowledge from linux users. We could have sorted the issue a lot quicker, so my apologies for that.