安装 jdk 和 NetBeans 存在许多依赖问题

安装 jdk 和 NetBeans 存在许多依赖问题
dpkg: dependency problems prevent configuration of openjdk-8-jre-headless:amd64:
 openjdk-8-jre-headless:amd64 depends on java-common (>= 0.28); however:
  Package java-common is not configured yet.

dpkg: error processing package openjdk-8-jre-headless:amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of ca-certificates-java:
 ca-certificates-java depends on openjdk-7-jre-headless (>= 7~u3-2.1.1~pre1-1) | java7-runtime-headless; however:
  Package openjdk-7-jre-headless is not installed.
  Package oracle-java9-installer which provides openjdk-7-jre-headless is not installed.
  Package oracle-java8-installer which provides openjdk-7-jre-headless is not installed.
  Package java7-runtime-headless is not installed.
  Package openjdk-8-jre-headless:amd64 which provides java7-runtime-headless is not configured yet.
  Package oracle-java9-installer which provides java7-runtime-headless is not installed.
  Package oracle-java8-installer which provides   
No apport report written because the error message indicates its a followup error from a previous failure.  
No apport report written because the error message indicates its a followup error from a previous failure.  
No apport report written because MaxReports is reached already.  
No apport report written because MaxReports is reached already.  
No apport report written because MaxReports is reached already.
  Package                              which provides java7-runtime-headless is not installed.
  Package openjdk-9-jre-headless:amd64 which provides java7-runtime-headless is not installed.

dpkg: error processing package ca-certificates-java (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of openjdk-8-jre:amd64:
 openjdk-8-jre:amd64 depends on openjdk-8-jre-headless (= 8u151-b12-0ubuntu0.16.04.2); however:
  Package openjdk-8-jre-headless:amd64 is not configured yet.
  Package oracle-java9-installer which provides openjdk-8-jre-headless is not installed.
  Package oracle-java8-installer which provides openjdk-8-jre-headless is not installed.

dpkg: error processing package openjdk-8-jre:amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of openjdk-8-jdk-headless:amd64:
 openjdk-8-jdk-headless:amd64 depends on openjdk-8-jre-headless (= 8u151-b12-0ubuntu0.16.04.2); however:
  Package openjdk-8-jre-headless:amd64 is not configured yet.
  Package oracle-java9-installer which provides openjdk-8-jre-headless is not installed.
  Package oracle-java8-installer which provides openjdk-8-jre-headless is not installed.

dpkg: error processing package openjdk-8-jdk-headless:amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of openjdk-8-jdk:amd64:
 openjdk-8-jdk:amd64 depends on openjdk-8-jre (= 8u151-b12-0ubuntu0.16.04.2); however:
  Package openjdk-8-jre:amd64 is not configured yet.
  Package oracle-java9-installer which provides openjdk-8-jre is not installed.
  Package oracle-java8-installer which provides openjdk-8-jre is not installed.
 openjdk-8-jdk:amd64 depends on openjdk-8-jdk-headless (= 8u151-b12-0ubuntu0.16.04.2); however:
  Package openjdk-8-jdk-headless:amd64 is not configured yet.
  Package oracle-java9-installer which provides openjdk-8-jdk-headless is not installed.
  Package oracle-java8-installer which provides openjdk-8-jdk-headless is not installed.

dpkg: error processing package openjdk-8-jdk:amd64 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 java-common
 openjdk-8-jre-headless:amd64
 ca-certificates-java
 openjdk-8-jre:amd64
 openjdk-8-jdk-headless:amd64
 openjdk-8-jdk:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)
rico@rico-Aspire-5750G:~$

结果sudo apt autoremove

rico@rico-Aspire-5750G:~$ sudo apt autoremove
[sudo] password for rico: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  default-jdk-doc java-wrappers junit junit-doc junit4-doc libantlr-java
  libantlr3-runtime-java libapache-pom-java libapr1 libaprutil1 libasm3-java
  libasm4-java libaspectj-java libatinject-jsr330-api-java
  libavalon-framework-java libbeansbinding-java libbsh-java libbytelist-java
  libcdi-api-java libcglib3-java libcommons-beanutils-java
  libcommons-codec-java libcommons-collections3-java libcommons-compress-java
  libcommons-digester-java libcommons-io-java libcommons-lang-java
  libcommons-logging-java libcommons-net-java libcommons-parent-java
  libequinox-osgi-java libexcalibur-logkit-java libfelix-framework-java
  libfelix-main-java libfelix-osgi-obr-java libfreemarker-java
  libgeronimo-interceptor-3.0-spec-java
  libgeronimo-j2ee-connector-1.5-spec-java libgeronimo-jta-1.1-spec-java
  libguava-java libhamcrest-java libhamcrest-java-doc libhtml5parser-java
  libhttpclient-java libhttpcore-java libicu4j-4.4-java libini4j-java
  libjavaewah-java libjcodings-java libjcommander-java libjemmy2-java
  libjgit-java libjna-java libjna-jni libjna-platform-java
  libjnlp-servlet-java libjoda-convert-java libjoda-time-java
  libjpa-2.1-spec-java libjsch-agent-proxy-java libjsch-java
  libjson-simple-java libjsr305-java libjsr311-api-java libjvyamlb-java
  libjzlib-java libkxml2-java liblog4j1.2-java liblucene3-contrib-java
  liblucene3-java libmail-java libmysql-java libnb-absolutelayout-java
  libnb-javaparser-java libnb-org-openide-modules-java
  libnb-org-openide-util-java libnb-org-openide-util-lookup-java
  libosgi-annotation-java libosgi-core-java libosgi-foundation-ee-java
  libpostgresql-jdbc-java libregexp-java libsdo-api-java
  libsequence-library-java libserf-1-1 libservlet2.5-java libservlet3.0-java
  libservlet3.1-java libsimple-validation-java libslf4j-java
  libstringtemplate-java libstringtemplate4-java libsvn-java libsvn1
  libsvnclientadapter-java libswing-layout-java libswingx-java
  libtrilead-ssh2-java libws-commons-util-java libxerces2-java
  libxml-commons-external-java libxml-commons-resolver1.1-java
  libyaml-snake-java openjdk-8-doc testng
0 to upgrade, 0 to newly install, 105 to remove and 18 not to upgrade.
6 not fully installed or removed.
After this operation, 387 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 261290 files and directories currently installed.)
Removing default-jdk-doc (2:1.8-56ubuntu2) ...
Removing java-wrappers (0.1.28) ...
Removing junit (3.8.2-8build1) ...
Removing junit-doc (3.8.2-8build1) ...
Removing junit4-doc (4.12-4ubuntu1) ...
Removing libstringtemplate-java (3.2.1-2) ...
Removing libantlr-java (2.7.7+dfsg-6ubuntu1) ...
Removing libstringtemplate4-java (4.0.8-2) ...
Removing libantlr3-runtime-java (3.5.2-4) ...
Removing libcommons-lang-java (2.6-6ubuntu2) ...
Removing libhttpclient-java (4.5.1-1) ...
Removing libsvnclientadapter-java (1.10.3-4) ...
Removing libsvn-java (1.9.3-2ubuntu1.1) ...
Removing libsvn1:amd64 (1.9.3-2ubuntu1.1) ...
Removing libserf-1-1:amd64 (1.3.8-1) ...
Removing libaprutil1:amd64 (1.5.4-1build1) ...
Removing libasm3-java (3.3.2-3) ...
Removing libcglib3-java (3.1+dfsg-1) ...
Removing libasm4-java (5.0.4-1) ...
Removing libaspectj-java (1.8.8-1) ...
Removing libguava-java (19.0-1) ...
Removing libcdi-api-java (1.0-2) ...
Removing libatinject-jsr330-api-java (1.0+ds1-2) ...
Removing libavalon-framework-java (4.2.0-9) ...
Removing libbeansbinding-java (1.2.1-1) ...
Removing testng (6.9.5-1) ...
Removing libbsh-java (2.0b4-17ubuntu1) ...
Removing libjvyamlb-java (0.2.5-2) ...
Removing libbytelist-java (1.0.12-3) ...
Removing libcommons-digester-java (1.8.1-4) ...
Removing libcommons-beanutils-java (1.9.2-3) ...
Removing libcommons-codec-java (1.10-1) ...
Removing libcommons-collections3-java (3.2.2-1) ...
Removing libcommons-compress-java (1.10-2) ...
Removing libcommons-io-java (2.4-2) ...
Removing libcommons-net-java (3.4-2ubuntu2) ...
Removing libequinox-osgi-java (3.8.1-8) ...
Removing libexcalibur-logkit-java (2.0-11ubuntu2) ...
Removing libfelix-main-java (5.0.0-3) ...
Removing libfelix-framework-java (4.6.1-1) ...
Removing libfelix-osgi-obr-java (1.0.2-3fakesync1) ...
Removing libfreemarker-java (2.3.23-3) ...
Removing libgeronimo-interceptor-3.0-spec-java (1.0.1-3fakesync1) ...
Removing libgeronimo-j2ee-connector-1.5-spec-java (2.0.0-1.1) ...
Removing libgeronimo-jta-1.1-spec-java (1.1.1-3ubuntu1) ...
Removing libhamcrest-java (1.3-5ubuntu1) ...
Removing libhamcrest-java-doc (1.3-5ubuntu1) ...
Removing libhtml5parser-java (1.4+r1.3.1-1) ...
Removing libhttpcore-java (4.4.4-1) ...
Removing libicu4j-4.4-java (4.4.2.2-2) ...
Removing libini4j-java (0.5.2-SNAPSHOT-5) ...
Removing libjgit-java (3.7.1-2) ...
Removing libjavaewah-java (0.6.12-1) ...
Removing libjcodings-java (1.0.17-1) ...
Removing libjcommander-java (1.48-1) ...
Removing libjemmy2-java (2.3.1.1-2) ...
Removing libjsch-agent-proxy-java (0.0.8-2ubuntu1) ...
Removing libjna-platform-java (4.2.2-1) ...
Removing libjna-java (4.2.2-1) ...
Removing libjna-jni (4.2.2-1) ...
Removing libjnlp-servlet-java (20120126-3) ...
Removing libjoda-convert-java (1.8.1-1) ...
Removing libjoda-time-java (2.9.2-1) ...
Removing libjpa-2.1-spec-java (2.1.0.v201304241213-1) ...
Removing libjsch-java (0.1.53-1ubuntu1) ...
Removing libjson-simple-java (1.1.1-3) ...
Removing libjsr305-java (0.1~+svn49-9) ...
Removing libjsr311-api-java (1.1.1-1) ...
Removing libjzlib-java (1.1.3-1) ...
Removing libkxml2-java (2.3.0+ds1-2) ...
Removing liblog4j1.2-java (1.2.17-7ubuntu1) ...
Removing liblucene3-contrib-java (3.6.2+dfsg-8) ...
Removing liblucene3-java (3.6.2+dfsg-8) ...
Removing libmail-java (1.5.5-1) ...
Removing libmysql-java (5.1.38-1) ...
Removing libnb-absolutelayout-java (8.1+dfsg2-3) ...
Removing libnb-javaparser-java (7.4-1) ...
Removing libnb-org-openide-modules-java (8.1+dfsg1-2) ...
Removing libsimple-validation-java (0.9-2) ...
Removing libnb-org-openide-util-java (8.1+dfsg1-2) ...
Removing libnb-org-openide-util-lookup-java (8.1+dfsg1-2) ...
Removing libosgi-core-java (6.0.0-1) ...
Removing libosgi-annotation-java (6.0.0-1) ...
Removing libosgi-foundation-ee-java (4.2.0-2) ...
Removing libpostgresql-jdbc-java (9.2-1002-1) ...
Removing libregexp-java (1.5-3build1) ...
Removing libsdo-api-java (1.1.1-1) ...
Removing libsequence-library-java (1.0.3-1) ...
Removing libservlet2.5-java (6.0.45+dfsg-1) ...
Removing libservlet3.0-java (7.0.68-1ubuntu0.1) ...
Removing libservlet3.1-java (8.0.32-1ubuntu1.4) ...
Removing libslf4j-java (1.7.14-3) ...
Removing libswing-layout-java (1.0.4-4) ...
Removing libswingx-java (1:1.6.2-2) ...
Removing libtrilead-ssh2-java (6401+svn158-1) ...
Removing libws-commons-util-java (1.0.1-9) ...
Removing libxerces2-java (2.11.0-7) ...
Removing libxml-commons-external-java (1.4.01-2build1) ...
Removing libxml-commons-resolver1.1-java (1.2-7build1) ...
Removing libyaml-snake-java (1.12-2) ...
Removing openjdk-8-doc (8u151-b12-0ubuntu0.16.04.2) ...
Removing libcommons-logging-java (1.2-1+build1) ...
Removing libcommons-parent-java (39-3) ...
Removing libapache-pom-java (10-2build1) ...
Removing libapr1:amd64 (1.5.2-3) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for doc-base (0.10.7) ...
Processing 5 removed doc-base files...
Registering documents with scrollkeeper...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Setting up java-common (0.56ubuntu2) ...
mkdir: cannot create directory ‘/etc/.java/.systemPrefs’: File exists
dpkg: error processing package java-common (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of openjdk-8-jre-headless:amd64:
 openjdk-8-jre-headless:amd64 depends on java-common (>= 0.28); however:
  Package java-common is not configured yet.

dpkg: error processing package openjdk-8-jre-headless:amd64 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.  
dpkg: dependency problems prevent configuration of ca-certificates-java:
 ca-certificates-java depends on openjdk-7-jre-headless (>= 7~u3-2.1.1~pre1-1) | java7-runtime-headless; however:
  Package openjdk-7-jre-headless is not installed.
  Package oracle-java9-installer which provides openjdk-7-jre-headless is not installed.
  Package oracle-java8-installer which provides openjdk-7-jre-headless is not installed.
  Package java7-runtime-headless is not installed.
  Package openjdk-8-jre-headless:amd64 which provides java7-runtime-headless is not configured yet.
  Package oracle-java9-installer which provides java7-runtime-headless is not installed.
  Package oracle-java8-installer which provides java7-runtime-headless is not installed.
  Package openjdk-9-jre-headless:amd64 which provides java7-runtime-headless is not installed.

dpkg: error processing package ca-certificates-java (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                          dpkg: dependency problems prevent configuration of openjdk-8-jre:amd64:
 openjdk-8-jre:amd64 depends on openjdk-8-jre-headless (= 8u151-b12-0ubuntu0.16.04.2); however:
  Package openjdk-8-jre-headless:amd64 is not configured yet.
  Package oracle-java9-installer which provides openjdk-8-jre-headless is not installed.
  Package oracle-java8-installer which provides openjdk-8-jre-headless is not installed.

dpkg: error processing package openjdk-8-jre:amd64 (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already. 
No apport report written because MaxReports is reached already.  
dpkg: dependency problems prevent configuration of openjdk-8-jdk-headless:amd64:
 openjdk-8-jdk-headless:amd64 depends on openjdk-8-jre-headless (= 8u151-b12-0ubuntu0.16.04.2); however:
  Package openjdk-8-jre-headless:amd64 is not configured yet.
  Package oracle-java9-installer which provides openjdk-8-jre-headless is not installed.
  Package oracle-java8-installer which provides openjdk-8-jre-headless is not installed.

dpkg: error processing package openjdk-8-jdk-headless:amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of openjdk-8-jdk:amd64:
 openjdk-8-jdk:amd64 depends on openjdk-8-jre (= 8u151-b12-0ubuntu0.16.04.2); however:
  Package openjdk-8-jre:amd64 is not configured yet.
  Package oracle-java9-installer which provides openjdk-8-jre is not installed.
  Package oracle-java8-installer which provides openjdk-8-jre is not installed.
 openjdk-8-jdk:amd64 depends on openjdk-8-jdk-headless (= 8u151-b12-0ubuntu0.16.04.2); howeve
No apport report written because MaxReports is reached already.  
error:  
  Package openjdk-8-jdk-headless:amd64 is not configured yet.
  Package oracle-java9-installer which provides openjdk-8-jdk-headless is not installed.
  Package oracle-java8-installer which provides openjdk-8-jdk-headless is not installed.

dpkg: error processing package openjdk-8-jdk:amd64 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 java-common
 openjdk-8-jre-headless:amd64
 ca-certificates-java
 openjdk-8-jre:amd64
 openjdk-8-jdk-headless:amd64
 openjdk-8-jdk:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)
rico@rico-Aspire-5750G:~$
rico@rico-Aspire-5750G:~$ cat /etc/apt/sources.list

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://au.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://au.archive.ubuntu.com/ubuntu/ xenial main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://au.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
# deb-src http://au.archive.ubuntu.com/ubuntu/ xenial-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://au.archive.ubuntu.com/ubuntu/ xenial universe
# deb-src http://au.archive.ubuntu.com/ubuntu/ xenial universe
deb http://au.archive.ubuntu.com/ubuntu/ xenial-updates universe
# deb-src http://au.archive.ubuntu.com/ubuntu/ xenial-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://au.archive.ubuntu.com/ubuntu/ xenial multiverse
# deb-src http://au.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://au.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
# deb-src http://au.archive.ubuntu.com/ubuntu/ xenial-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://au.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src http://au.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.

deb http://security.ubuntu.com/ubuntu xenial-security main restricted
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse

答案1

  1. 如果您在 中启用了任何 Oracle 或 Java PPA /etc/apt/sources.list,则可以通过在包含java或的每一行前面添加oracle一个#字符(将该行变为注释)来删除它们。

    sudo add-apt-repository --remove ppa:PPANAME
    
  2. 更新可用软件列表。

    sudo apt update
    
  3. 卸载问题中最后一个代码块中的所有软件包,并卸载从 Ubuntu 14.04 升级到 Ubuntu 16.04 后遗留的一些不必要的软件包。

    sudo apt remove java-common oracle-java9-installer oracle-java8-installer openjdk-9-jre-headless openjdk-8-jre-headless default-jre-headless openjdk-8-jre default-jre openjdk-8-jdk-headless openjdk-8-jdk default-jdk-headless default-jdk ant ant-optional antlr3 aspectj libgeronimo-jpa-2.0-spec-java bnd javahelp2 junit4 libbindex-java libgeronimo-jms-1.1-spec-java libeclipselink-java libnb-platform18-java libsqljet-java libsvnkit-java libnb-ide14-java libnb-java5-java libnb-platform-devel-java libnb-apisupport3-java netbeans ca-certificates-java libosgi-compendium-java libgeronimo-osgi-support-java libgeronimo-validation-1.0-spec-java   
    sudo apt remove -f openjdk-7-jre-headless  
    sudo apt remove -f oracle-java8-installer  
    sudo apt remove -f oracle-java9-installer  
    sudo apt remove -f ca-certificates-java
    
  4. 重新配置包。运行以下命令之前,请关闭 NetBeans 和 Java:

    sudo dpkg --configure -a
    
  5. NetBeans 与操作系统的默认 Java 一起安装时效果最佳。打开终端并输入:

    sudo apt install default-jdk netbeans # This installs jdk version 8 in 16.04. 
    

    Ubuntu 16.04 默认存储库中的 NetBeans 版本是 NetBeans 8,其兼容 Java 版本为 Java 8。

如果您之前没有安装过 Oracle Java,NetBeans 应该会自动检测 Java 路径,但由于您之前确实安装了 Oracle Java,我预计您需要手动重新配置 Java 路径,以便 NetBeans 识别它。为了将 C/C++ 功能添加到 NetBeans,请按照以下步骤操作这个答案

相关内容