可爱熊个人博客

RedHat6.0上安装jdk1.7

 

1.解压安装rpm包
[kevin@localhost software]$ rpm -ivh jdk-7u6-linux-i586.rpm
  报错:error: can’t create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)
错误原因:当前非root用户
2.切换到root用户
[kevin@localhost software]$ su
  输入root用户密码
3.输入命令1,得到以下信息
[root@localhost software]# rpm -ivh jdk-7u6-linux-i586.rpm
Preparing…                ########################################### [100%]
   1:jdk                    ########################################### [100%]
Unpacking JAR files…
        rt.jar…
Error: Could not open input file: /usr/java/jdk1.7.0_06/jre/lib/rt.pack
        jsse.jar…
Error: Could not open input file: /usr/java/jdk1.7.0_06/jre/lib/jsse.pack
        charsets.jar…
Error: Could not open input file: /usr/java/jdk1.7.0_06/jre/lib/charsets.pack
        tools.jar…
Error: Could not open input file: /usr/java/jdk1.7.0_06/lib/tools.pack
        localedata.jar…
Error: Could not open input file: /usr/java/jdk1.7.0_06/jre/lib/ext/localedata.pack
        plugin.jar…
Error: Could not open input file: /usr/java/jdk1.7.0_06/jre/lib/plugin.pack
        javaws.jar…
Error: Could not open input file: /usr/java/jdk1.7.0_06/jre/lib/javaws.pack
        deploy.jar…
Error: Could not open input file: /usr/java/jdk1.7.0_06/jre/lib/deploy.pack
[root@localhost software]# ll
4.查看java暗装在哪里
[root@localhost software]# whereis java
java: /usr/bin/java /etc/java /usr/lib/java /usr/share/java /usr/share/man/man1/java.1.gz
5.设置java幻境变量
先备份一下配置文件
[root@localhost jdk1.7.0_06]# cp /etc/profile /etc/profile_backup
[root@localhost jdk1.7.0_06]# vi /etc/profile
在该文件的最后添加以下代码:
set JAVA_HOME=/usr/java/jdk1.7.0_06
export JAVA_HOME
set PATH=$PATH:$JAVA_HOME/bin
export PATH
set CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export CLASSPATH
6.保存退出,在命令行上输入java javac出现了我们熟悉的提示
输入jdk -version
[kevin@localhost ~]$ java -version
java version “1.6.0_17”
OpenJDK Runtime Environment (IcedTea6 1.7.4) (rhel-1.21.b17.el6-i386)

OpenJDK Client VM (build 14.0-b16, mixed mode)

Comments are closed.