1.下载jdk1.7.0_67并且解压,放知道/usr/local/lib/jvm目录下
tar zxvf jdk1.7.0_67.tar.gz
sudo mv jdk1.7.0_67 /usr/local/lib/jvm
2.编辑~/.bashrc文件,添加如下内容。
JAVA_HOME后的内容为你自定义的JDK存放目录
export JAVA_HOME=/usr/local/lib/jvm/jdk1.7.0_67
export JRE_HOME=${JAVA_HOME}/jre
exportCLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
3.设置JDK默认版本
sudo update-alternatives --install "/usr/bin/java/" "java" "/usr/local/lib/jvm/jdk1.7.0_67/bin/java" 300
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/lib/jvm/jdk1.7.0_67/bin/javac" 300
sudo update-alternatives --install "/usr/bin/jar" "jar" "/usr/local/lib/jvm/jdk1.7.0_67/bin/jar" 300
sudo update-alternatives --install "/usr/bin/javah" "javah" "/usr/local/lib/jvm/jdk1.7.0_67/bin/javah" 300
sudo update-alternatives --install "/usr/bin/javap" "javap" "/usr/local/lib/jvm/jdk1.7.0_67/bin/javap" 300
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/lib/jvm/jdk1.7.0_67/bin/javaws" 300
sudo update-alternatives --set java /usr/local/lib/jvm/jdk1.7.0_67/bin/java
sudo update-alternatives --set javac /usr/local/lib/jvm/jdk1.7.0_67/bin/javac
sudo update-alternatives --set jar /usr/local/lib/jvm/jdk1.7.0_67/bin/jar
sudo update-alternatives --set javah /usr/local/lib/jvm/jdk1.7.0_67/bin/javah
sudo update-alternatives --set javap /usr/local/lib/jvm/jdk1.7.0_67/bin/javap
sudo update-alternatives --set javaws /usr/local/lib/jvm/jdk1.7.0_67/bin/javaws
4.检查
java -version
mik3y@mac:~$ java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
5.使火狐浏览器支持java插件
sudo find / -name libnpjp2.so
/usr/local/lib/jvm/jdk1.7.0_67/jre/lib/amd64/libnpjp2.so
cd ~
mkdir -pv .mizilla/plugins
cd .mizilla/plugins
ln -sf /usr/local/lib/jvm/jdk1.7.0_67/jre/lib/amd64/libnpjp2.so ~/.mizilla/plugins
Firefox:
URL地址栏中输入:about:plugins会浏览到JAVA TM 相关的内容,接下来测试
http://www.java.com/en/download/installed.jsp