openjdk-8 não está instalado corretamente

2

Eu acidentalmente instalei openjdk-9-jre-headless quando na verdade eu queria openjdk-8-jre-headless usando

sudo apt install openjdk-9-jre-headless

Quando percebi, fiz

sudo apt remove --purge openjdk-9-jre-headless
sudo apt install openjdk-8-jre-headless

Agora eu tenho uma situação estranha aqui:

~$ java --version

The program 'java' can be found in the following packages:
 * default-jre
 * gcj-5-jre-headless
 * openjdk-8-jre-headless
 * gcj-4.8-jre-headless
 * gcj-4.9-jre-headless
 * openjdk-9-jre-headless
Try: sudo apt install <selected package>

Mas:

~$ sudo apt install openjdk-8-jre-headless

Reading package lists... Done
Building dependency tree
Reading state information... Done
openjdk-8-jre-headless is already the newest version (8u131-b11-2ubuntu1.16.04.3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

O que tenho que fazer aqui?

EDITAR:

Eu já tentei

~$ sudo apt install openjdk-8-jre-headless --reinstall

Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/27.0 MB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 160472 files and directories currently installed.)
Preparing to unpack .../openjdk-8-jre-headless_8u131-b11-2ubuntu1.16.04.3_amd64.deb ...
Unpacking openjdk-8-jre-headless:amd64 (8u131-b11-2ubuntu1.16.04.3) over (8u131-b11-2ubuntu1.16.04.3) ...
Setting up openjdk-8-jre-headless:amd64 (8u131-b11-2ubuntu1.16.04.3) ...
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-9-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
    
por derHugo 16.10.2017 / 15:14

2 respostas

1

Ok, percebi:

sudo apt remove --purge openjdk-8-jre-headless
sudo apt autoremove
sudo apt install --reinstall openjdk-8-jre-headless

Agora eu recebo como esperado

~$  java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)
    
por derHugo 16.10.2017 / 15:30
0

O OP resolveu removendo o java8 primeiro e depois reinstalando-o. No entanto, nem sempre é possível, se você já tiver dependências de java, por exemplo, um servidor apache em execução ou outras coisas que requerem o tempo de execução de java. Nesse caso, primeiro remova o java9 e faça o seguinte executando diretamente update-alternatives :

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java" 1

modifique o caminho para java8, se necessário.

    
por HuStmpHrrr 23.01.2018 / 20:49