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

[email protected]:~# 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.
[email protected]:~# 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)
[email protected]:~#

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

[email protected]:/var/lib/dpkg/info# java -version
-su: /usr/bin/java: No such file or directory
[email protected]:/var/lib/dpkg/info# update-alternatives --config java
update-alternatives: error: no alternatives for java
[email protected]:/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.

[email protected]:/var/lib/dpkg/info# dpkg --get-selections | awk '/oracle-java/ && /installer/ {print "sudo apt-get purge "$1}'
[email protected]:/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
[email protected]:/var/lib/dpkg/info# dpkg --get-selections | awk '/oracle-java/ && /installer/ {system("sudo apt-get purge "$1)}'
[email protected]:/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.
[email protected]:/var/lib/dpkg/info#

You could try this alternate solution maybe:

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

[email protected]:/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.
[email protected]:/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.

[email protected]:~/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
[email protected]:~/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
[email protected]:~/Downloads$ cp jre-8u45-linux-x64 (1).tar.gz
bash: syntax error near unexpected token ('
[email protected]:~/Downloads$ cp jre-8u45-linux-x64 (1).tar.gz /opt/
bash: syntax error near unexpected token
('
[email protected]:~/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
[email protected]:~/Downloads$ sudo cp "jre-8u45-linux-x64 (1).tar.gz" /opt/
[sudo] password for michael:
[email protected]:~/Downloads$ cd /opt
[email protected]:/opt$ ls
firefox google jre-8u45-linux-x64 (1).tar.gz spotify wine-staging
[email protected]:/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
[email protected]:/opt$ sudo tar -xzf jre-8u45-linux-x64\ (1).tar.gz
[email protected]:/opt$ ls
firefox jre1.8.0_45 spotify
google jre-8u45-linux-x64 (1).tar.gz wine-staging
[email protected]:/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
[email protected]:/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
[email protected]:/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.
[email protected]:/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?

[email protected]:~$ 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
[email protected]:~$

@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.