Remove broken java installation (linux)

邮差的信 提交于 2019-12-12 11:19:56

问题


I somehow messed up my Java installation and now I get this:

$ sudo apt-get remove jre1.8.0_66
(Reading database ... 55212 files and directories currently installed.)
Removing jre1.8.0-65 ...
find: `/usr/java/*': No such file or directory
/var/lib/dpkg/info/jre1.8.0-65.postrm: line 586: /usr/sbin/alternatives: No such file or directory
dpkg: error processing jre1.8.0-65 (--remove):
 subprocess installed post-removal script returned error exit status 127
Errors were encountered while processing:
 jre1.8.0-65
E: Sub-process /usr/bin/dpkg returned an error code (1)

How can I force to remove this? The folder with the java files is empty, but this shows up everytime i install something...

EDIT: Linux says it's half installed/removed:

0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.

回答1:


/usr/sbin/alternatives: No such file or directory

There is no /usr/sbin/alternatives in Debian, Ubuntu, or their clones. Instead, there is /usr/bin/update-alternatives.

I suggest a temporary symbolic link to work around the badly converted RPM package:

mkdir -p /usr/sbin
ln -s /usr/bin/update-alternatives /usr/sbin/alternatives



回答2:


Verify avaialble installations in your machine : -

 sudo update-alternatives --config java

There are 3 choices for the alternative java (providing /usr/bin/java).  


     Selection    Path                                     Priority   Status
    ------------------------------------------------------------
      0            /usr/lib/jvm/java-6-oracle/jre/bin/java   3         auto mode
    * 1            /usr/lib/jvm/java-6-oracle/jre/bin/java   3         manual mode
      2            /usr/lib/jvm/java-7-oracle/jre/bin/java   2         manual mode
      3            /usr/lib/jvm/java-8-oracle/jre/bin/java   1         manual mode

    Press <enter> to keep the current choice[*], or type selection number:

Now remove existing symbolic links first

sudo update-alternatives --remove "java" "/usr/lib/jvm/java-8-oracle/jre/bin/java"
sudo update-alternatives --remove "java" "/usr/lib/jvm/java-7-oracle/jre/bin/java"
sudo update-alternatives --remove "java" "/usr/lib/jvm/java-6-oracle/jre/bin/java"

-------javac

sudo update-alternatives --config javac
There are 3 choices for the alternative java (providing /usr/bin/javac).

  Selection    Path                                     Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-6-oracle/jre/bin/javac   3         auto mode
* 1            /usr/lib/jvm/java-6-oracle/jre/bin/javac   3         manual mode
  2            /usr/lib/jvm/java-7-oracle/jre/bin/javac  2         manual mode
  3            /usr/lib/jvm/java-8-oracle/jre/bin/javac  1         manual mode

Press <enter> to keep the current choice[*], or type selection number: 

Now remove symbolic links

sudo update-alternatives --remove "javac" "/usr/lib/jvm/java-8-oracle/jre/bin/javac"
sudo update-alternatives --remove "javac" "/usr/lib/jvm/java-7-oracle/jre/bin/javac"
sudo update-alternatives --remove "javac" "/usr/lib/jvm/java-6-oracle/jre/bin/javac"

--if you see any issue with javaws than follow same steps to remvoe

Its time to set the symbolic links to your location, download the linux java version which you like and move the unziped directories to proper location like /usr/lib/jvm/ which common naming standard insted of one which you got from site name like java-6-oracle

sudo update-alternatives --set java /usr/lib/jvm/java-8-oracle/jre/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/java-8-oracle/jre/bin/javac
sudo update-alternatives --set javaws /usr/lib/jvm/java-8-oracle/jre/bin/javaws

Same like whichever the version you want just run above commands after placing in required location.

Change the jave version by using sudo update-alternatives --config java and selete the options.

leave the comment if any assistence required.



来源:https://stackoverflow.com/questions/33635075/remove-broken-java-installation-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!