删除破碎的java安装(linux)

时间:2015-11-10 16:41:08

标签: linux apt-get

我以某种方式弄乱了我的Java安装,现在我明白了:

$ 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)

如何强行删除?带有java文件的文件夹是空的,但每次安装时都会显示...

编辑:Linux说已经安装/删除了一半:

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

2 个答案:

答案 0 :(得分:7)

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

Debian,Ubuntu或其克隆中没有/usr/sbin/alternatives。 相反,有/usr/bin/update-alternatives

我建议使用一个临时的符号链接来解决转换不良的RPM包:

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

答案 1 :(得分:0)

验证机器中的可用安装: -

 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:

现在首先删除现有的符号链接

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: 

现在删除符号链接

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"

- 如果您发现javaws存在任何问题,请执行与remvoe相同的步骤

是时候设置符号链接到你的位置,下载你喜欢的linux java版本并将unziped目录移动到 正确的位置,例如/ usr / lib / jvm /你从网站名称中获得的常用命名标准,例如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

与您希望在放入所需位置后在命令之上运行的版本相同。

使用sudo update-alternatives --config java更改jave版本并选择选项。

如果需要任何帮助,请留下评论。