假设您安装了 OpenJDK6:
sudo apt-get install openjdk-6-jdk
在 Ubuntu 64 位中,确保路径对您的安装有效(如果使用 32 位版本,请更改):
/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java
/usr/lib/jvm/java-6-openjdk-amd64/bin/javac
设置更新替代方案:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java-6-openjdk-amd64/bin/javac" 1
sudo update-alternatives --set java /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/java-6-openjdk-amd64/bin/javac
或者,确保检查 Java 和编译器的正确版本:
sudo update-alternatives --config java
sudo update-alternatives --config javac
列出已安装的 Java 替代品:
sudo update-alternatives --list java
sudo update-alternatives --list javac