ubuntu 16.04 安装jdk9错误

转自:https://askubuntu.com/questions/769467/can-not-install-openjdk-9-jdk-because-it-tries-to-overwrite-file-aready-includ

  1. Normally try to install the openjdk-9-jdk package, preferably using the package manager apt:

    sudo apt install openjdk-9-jdk
    

    This will install all of its dependencies and also download the binary package file. It should be stored at /var/cache/apt/archives/openjdk-9-jdk_9~b114-0ubuntu1_amd64.deb now, but the file name's second half may differ in case you're having a different version.

    Please note that we expect this single command to fail with the error message described in the question. Ignore the error, we'll take care of that in the next steps.

  2. The dependency packages were not fully configured yet because the installation of openjdk-9-jdk failed and got aborted. We have to do that manually now and simply trigger the configuration of all not yet configured packages:

    sudo dpkg --configure -a
    
  3. Finally we install our openjdk-9-jdk package. Therefore we use the downloaded and cached binary package file we got in step 1. We have to add the --force-overwrite flag to make the package manager ignore our doubly provided file and quietly overwrite it.

    sudo dpkg -i --force-overwrite '/var/cache/apt/archives/openjdk-9-jdk_9~b114-0ubuntu1_amd64.deb'
    

    You may have to adapt the file name in case you're having a different version, or just use tab-completion to enter the file name: press Tab after having entered the file name up to the underscore (...openjdk-9-jdk_) and it should autocomplete the correct file name.