首頁 > 軟體

OpenSUSE下安裝JDK

2020-06-16 17:33:09

openSUSE自帶了OpenJDK,安裝Oracle JDK後,需要使用alternatives切換系統預設使用的JDK版本。

1)安裝JDK:

linuxidc@linux-linuxidc:~/下載> sudo zypper install jdk-8u66-linux-x64.rpm -y 
...
/var/tmp/rpm-tmp.DfGrcZ: line 638: /usr/sbin/alternatives: No such file or directory
/var/tmp/rpm-tmp.DfGrcZ: line 650: /usr/sbin/alternatives: No such file or directory
warning: %post(jdk1.8.0_66-2000:1.8.0_66-fcs.x86_64) scriptlet failed, exit status 127

有如上的報錯,“/usr/sbin/alternatives”這個檔案找不到。openSUSE相應的檔名是update-alternatives,嘗試做了軟連線,會報新的錯誤:

update-alternatives: error: alternative javaws can't be slave of java: it is a slave of javaplugin
update-alternatives: error: alternative javaws can't be slave of javac: it is a slave of javaplugin
warning: %post(jdk1.8.0_66-2000:1.8.0_66-fcs.x86_64) scriptlet failed, exit status 2

看來openSUSE和Oracle JDK不是很友好啊,需要手動完成後續的必要步驟(從網上找的,可能不是安裝指令碼的全部後續操作)。

2)用alternatives宣告jdk版本並設為預設:

linuxidc@linux-linuxidc:~/下載> sudo /usr/sbin/update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk1.8.0_66/bin/java" 40
linuxidc@linux-linuxidc:~/下載> sudo /usr/sbin/update-alternatives --install "/usr/lib64/browser-plugins/javaplugin.so" "javaplugin" "/usr/java/jdk1.8.0_66/jre/lib/amd64/libnpjp2.so" 40


IT145.com E-mail:sddin#qq.com