我已经按照本指南。当我运行时sudo update-java-alternatives -s java-7-oracle
,它给我:
update-alternatives: error: no alternatives for xulrunner-1.9-javaplugin.so.
update-alternatives: error: alternative /usr/lib/jvm/java-7-oracle/jre/bin/jexec for jexec not registered, not setting.
update-alternatives: error: alternative /usr/lib/jvm/java-7-oracle/jre/lib/amd64/libnpjp2.so for mozilla-javaplugin.so not registered, not setting.
update-alternatives: error: no alternatives for xulrunner-1.9-javaplugin.so.
怎么回事?我用的是ubuntu12.04 amd64。
答案1
Properly installing Oracle java 7 JDK and JRE on Ubuntu 64Bits and beased distributions.
在 Ubuntu 64Bits 和 beased 发行版上正确安装 Oracle java 7 JDK 和 JRE。
选项 1:逐步
打开终端窗口(uxterm 或任何其他终端仿真器)
以 root 身份运行
sudo -i
cd /
确保命令“apt-add-repository”正常运行(某些 Ubuntu 64 位和基于发行版的已知错误)
aptitude update
aptitude install python-software-properties
安装 Oracle java PPA
apt-add-repository ppa:webupd8team/java
安装 Oracle java
aptitude update
aptitude install oracle-java7-jdk oracle-java7-set-default oracle-java7-installer oracle-java7-plugin
修复已知的 Oracle java 问题:第 1 部分。创建目录“/usr/lib/xulrunner-addons/plugins/”
mkdir -p /usr/lib/xulrunner-addons/plugins
修复已知的 Oracle Java 问题:第 2 部分。注册缺失的替代方案
update-alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so /usr/lib/jvm/java-7-oracle/jre/lib/amd64/libnpjp2.so 1
update-alternatives --set mozilla-javaplugin.so /usr/lib/jvm/java-7-oracle/jre/lib/amd64/libnpjp2.so
update-alternatives --install /usr/lib/xulrunner-addons/plugins/libjavaplugin.so xulrunner-1.9-javaplugin.so /usr/lib/jvm/java-7-oracle/jre/lib/amd64/libnpjp2.so 1
update-alternatives --set xulrunner-1.9-javaplugin.so /usr/lib/jvm/java-7-oracle/jre/lib/amd64/libnpjp2.so
修复已知的 Oracle java 问题:第 3 部分。更正“/usr/lib/jvm/.java-7-oracle.jinfo”中“jexec”文件的位置
sed -i 's@jre jexec /usr/lib/jvm/java-7-oracle/jre/bin/jexec@jre jexec /usr/lib/jvm/java-7-oracle/jre/lib/jexec@g' /usr/lib/jvm/.java-7-oracle.jinfo
更新 Java 替代品,使 Oracle Java 成为系统上的默认 Java
update-java-alternatives -s java-7-oracle
卸载 OpenJDK java 文件
aptitude purge openjdk-7-jre openjdk-7-jre-headless openjdk-7-jre-lib default-jre default-jre-headless icedtea-7-jre-jamvm
退出“root”用户
exit
关闭终端窗口
exit
选项 2:一次性脚本
打开终端窗口(uxterm 或任何其他终端仿真器)
sudo -i
cd /
aptitude update
aptitude install python-software-properties
apt-add-repository ppa:webupd8team/java
aptitude update
aptitude install oracle-java7-jdk oracle-java7-set-default oracle-java7-installer oracle-java7-plugin
mkdir -p /usr/lib/xulrunner-addons/plugins
update-alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so /usr/lib/jvm/java-7-oracle/jre/lib/amd64/libnpjp2.so 1
update-alternatives --set mozilla-javaplugin.so /usr/lib/jvm/java-7-oracle/jre/lib/amd64/libnpjp2.so
update-alternatives --install /usr/lib/xulrunner-addons/plugins/libjavaplugin.so xulrunner-1.9-javaplugin.so /usr/lib/jvm/java-7-oracle/jre/lib/amd64/libnpjp2.so 1
update-alternatives --set xulrunner-1.9-javaplugin.so /usr/lib/jvm/java-7-oracle/jre/lib/amd64/libnpjp2.so
sed -i 's@jre jexec /usr/lib/jvm/java-7-oracle/jre/bin/jexec@jre jexec /usr/lib/jvm/java-7-oracle/jre/lib/jexec@g' /usr/lib/jvm/.java-7-oracle.jinfo
update-java-alternatives -s java-7-oracle
aptitude purge openjdk-7-jre openjdk-7-jre-headless openjdk-7-jre-lib default-jre default-jre-headless icedtea-7-jre-jamvm
exit
exit