解除安裝 Java 後,重新安裝 Java 套件會出現 unmet dependency 錯誤

解除安裝 Java 後,重新安裝 Java 套件會出現 unmet dependency 錯誤

我按照這個卸載了java教學然後我嘗試再次安裝它。我輸入:

sudo apt-get update

一切都很好,然後我運行這個sudo apt-get install default-jdk,我得到:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 default-jdk : Depends: default-jre (= 1:1.6-43ubuntu2)
               Depends: openjdk-6-jdk (>= 6b23~pre11-1ubuntu1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

請問我該如何解決這個問題?

我努力了

sudo apt-get clean
sudo apt-get autoclean
sudo apt-get -f install

列印

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

然後:

sudo dpkg --configure -a
sudo apt-get -f install

列印

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

我也嘗試過:

sudo apt-get install -f default-jre openjdk-6-jdk  # I also get the same error without the -f option

列印:

The following packages have unmet dependencies: 
 default-jre : Depends: openjdk-6-jre (>= 6b23~pre11-1ubuntu1~)    
 openjdk-6-jdk : Depends: openjdk-6-jre (= 6b39-1.13.11-0ubuntu0.12.04.1)  
                 Recommends: libxt-dev but it is not going to be installed  
E: Unable to correct problems, you have held broken packages.

答案1

我嘗試安裝sudo apt-get install openjdk-6-jre,然後發現缺少其他一些軟體包。然後我嘗試安裝該軟體包,然後發現其他一些軟體包丟失了。

3次之後,我成功安裝了最後一個軟體包,並從最後開始安裝所有缺少的軟體包,然後我終於安裝了!

相關內容