首先,选择下载Linux X86下的 jdk-6u30-linux-i586.bin,下载地址:[url]http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u30-download-1377139.html[/url]
其次,把JDK拷贝到指定目录,然后解压缩拷贝后的文件到指定目录,具体命令如下:
$sudo cp jdk-6u30-linux-i586.bin /usr/lib/jvm
$cd /usr/lib/jvm
$sudo ./jdk-6u30-linux-i586.bin
$sudo mv jdk1.6.0_30/ java-1.6.0_30-sun/
$sudo ln -s java-1.6.0_30-sun java-6-sun
$sudo rm jdk-6u30-linux-i586.bin
最后就是配置环境变量了
$sudo vi /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java-6-sun/bin"
CLASSPATH="/usr/lib/jvm/java-6-sun/lib"
JAVA_HOME="/usr/lib/jvm/java-6-sun"
告诉系统使用的是sun的JDK,而非OPenJDK了:
$sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-6-sun/bin/java 300
$sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-6-sun/bin/javac 300
$sudo update-alternatives --config java
此时屏幕显示,选择路径优先级状态,输入你想要选择的jdk,然后按回车.
其次,把JDK拷贝到指定目录,然后解压缩拷贝后的文件到指定目录,具体命令如下:
$sudo cp jdk-6u30-linux-i586.bin /usr/lib/jvm
$cd /usr/lib/jvm
$sudo ./jdk-6u30-linux-i586.bin
$sudo mv jdk1.6.0_30/ java-1.6.0_30-sun/
$sudo ln -s java-1.6.0_30-sun java-6-sun
$sudo rm jdk-6u30-linux-i586.bin
最后就是配置环境变量了
$sudo vi /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java-6-sun/bin"
CLASSPATH="/usr/lib/jvm/java-6-sun/lib"
JAVA_HOME="/usr/lib/jvm/java-6-sun"
告诉系统使用的是sun的JDK,而非OPenJDK了:
$sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-6-sun/bin/java 300
$sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-6-sun/bin/javac 300
$sudo update-alternatives --config java
此时屏幕显示,选择路径优先级状态,输入你想要选择的jdk,然后按回车.