linux 下安装JDK
1.下载jdk-7-linux-x64.rpm(http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html)
2. su切换到root权限
3. /usr/java/jdk1.7.0 rpm -ivh jdk-7-linux-x64.rpm,默认安装路径为 /usr/java/jdk1.7.0
4. vi /etc/profile
5. 在profile最后追加:
[plain] view plaincopy
export JAVA_HOME=/usr/java/jdk1.7.0
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
注意中间的链接符号是冒号不是分号!
6. source /etc/profile
7. 安装update-alternatives
update-alternatives --install /usr/bin/java java /usr/java/jdk1.7.0/bin/java 60
配置jdk
update-alternatives --config java
然后出现
[plain] view plaincopy
共有 2 个程序提供“java”。
选择 命令
-----------------------------------------------
*+ 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
2 /usr/java/jdk1.7.0/bin/java
按 Enter 来保存当前选择[+],或键入选择号码:2
回车即可。
java -version 输出
[plain] view plaincopy
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)