linux下安装JDK1.7

linux下安装JDK1.7
安装JDK1.7时的问题及解决过程:
1.rpm后可能出现N多Error,不要怕,继续向下走:
[husher@localhost tool]$ rpm -ivh jdk-7u15-linux-i586.rpm
error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)
[husher@localhost tool]$ su
Password:
[root@localhost tool]# rpm -ivh jdk-7u15-linux-i586.rpm
Preparing...                ########################################### [100%]
   1:jdk                    ########################################### [100%]
Unpacking JAR files...
    rt.jar...
Error: Could not open input file: /usr/java/jdk1.7.0_15/jre/lib/rt.pack
    jsse.jar...
Error: Could not open input file: /usr/java/jdk1.7.0_15/jre/lib/jsse.pack
    charsets.jar...
Error: Could not open input file: /usr/java/jdk1.7.0_15/jre/lib/charsets.pack
    tools.jar...
Error: Could not open input file: /usr/java/jdk1.7.0_15/lib/tools.pack
    localedata.jar...
Error: Could not open input file: /usr/java/jdk1.7.0_15/jre/lib/ext/localedata.pack
    plugin.jar...
Error: Could not open input file: /usr/java/jdk1.7.0_15/jre/lib/plugin.pack
    javaws.jar...
Error: Could not open input file: /usr/java/jdk1.7.0_15/jre/lib/javaws.pack
    deploy.jar...
Error: Could not open input file: /usr/java/jdk1.7.0_15/jre/lib/deploy.pack

2.配置$PATH:vi /etc/profile
#在/etc/profile的最后加上这一段就好了
set JAVA_HOME=/usr/java/jdk1.7.0_15
export JAVA_HOME
set PATH=$PATH:$JAVA_HOME
export PATH
set CLASSPATH=.:JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export CLASSPATH

3.看看jdk是否安装成功:
[root@localhost tool]# java -version
java version "1.7.0_15"
Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
Java HotSpot(TM) Client VM (build 23.7-b01, mixed mode, sharing)
[root@localhost tool]# javac -version
javac 1.7.0_15

你可能感兴趣的:(linux)