ubuntu 17.10 無法安裝jdk8

ubuntu 17.10 無法安裝jdk8

我使用以下程式碼安裝 jdk 8 並添加存儲庫

sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update

之後,當我嘗試使用以下命令安裝 Java 時,

sudo apt-get install oracle-java8-installer

我收到訊息,代碼回應是,

Reading package lists... Done
Building dependency tree      
Reading state information... Done
oracle-java8-installer is already the newest version (8u151-1~webupd8~0).
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.

答案1

oracle-java8-installer 已經是最新版本

這是當您嘗試安裝相同軟體包兩次時收到的錯誤訊息,因為該軟體包已安裝。要證明它,請執行以下命令來顯示是否安裝了 oracle-java8-installer:

apt policy oracle-java8-installer  

當您嘗試安裝 oracle-java8-installer 時,您收到以下錯誤訊息:

下載完成。
正在刪除過時的快取下載...
sha256sum 不符 jdk-8u151-linux-x64.tar.gz
未安裝 Oracle JDK 8。
dpkg:處理套件 oracle-java8-installer 時發生錯誤(--configure):
子進程安裝的安裝後腳本回傳錯誤退出狀態 1
處理時遇到錯誤:oracle-java8-installer
E: 子進程 /usr/bin/dpkg 回傳錯誤代碼 (1)

apt說oracle-java8-installer已安裝但java -version找不到java,所以一定是沒有正確安裝,因為出現sha256sum mismatch錯誤,這意味著jdk-8u151-linux-x64.tar.gz沒有被oracle正確下載-java8-安裝程序腳本。

您可能遇到與其他人相同的問題,即 oracle-java8-installer 腳本無法正常運作:當我嘗試安裝或刪除任何軟體時,會發生錯誤,請任何人幫助我所以訪問官方Oracle Java 9 網站,從那裡下載 jdk-9.0.1_linux-x64_bin.tar.gz,並按照此答案中的說明進行安裝:如何安裝 Sun/Oracle 專有的 Java JDK 6/7/8 或 JRE?

答案2

確認其安裝的另一種方法是從終端機執行以下命令:

 dpkg-query -l oracle-java8-installer

你應該看到這個:

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                               Version                Architecture           Description
+++-==================================-======================-======================-=========================================================================
ii  oracle-java8-installer             8u151-1~webupd8~0      all                    Oracle Java(TM) Development Kit (JDK) 8

第二個i表示已安裝。

man dpkg-query

-l, --list [package-name-pattern...]
              List  packages  matching  given  pattern.  If  no package-name-pattern is given, list all packages in /var/lib/dpkg/status, excluding the ones
              marked as not-installed (i.e. those which have been previously purged). Normal shell wildcard characters are allowed in  package-name-pattern.
              Please  note  you  will  probably have to quote package-name-pattern to prevent the shell from performing filename expansion. For example this
              will list all package names starting with “libc6”:

                dpkg-query -l 'libc6*'

              The first three columns of the output show the desired action, the package status, and errors, in that order.

              Desired action:
                u = Unknown
                i = Install
                h = Hold
                r = Remove
                p = Purge

              Package status:
                n = Not-installed
                c = Config-files
                H = Half-installed
                U = Unpacked
                F = Half-configured
                W = Triggers-awaiting
                t = Triggers-pending
                i = Installed

              Error flags:
                <empty> = (none)
                R = Reinst-required

              An uppercase status or error letter indicates the package is likely to cause severe problems. Please refer to dpkg(1)  for  information  about
              the above states and flags.

              The  output  format  of this option is not configurable, but varies automatically to fit the terminal width. It is intended for human readers,
              and is not easily machine-readable. See -W (--show) and --showformat for a way to configure the output format.

相關內容