为熟悉linux命令以及常用软件配置,在windows虚拟机上安装了个RedHat6,然后在上面安装jdk1.7
下载jdk的过程就不说了,以下描述的是oracle官网上的rpm格式的jdk包,安装步骤如下:
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
修改为:
export JAVA_HOME=/usr/java/jdk1.7.0_06
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
执行source命令让新加的配置项改动生效
[root@localhost kevin]# source /etc/profile
6.保存退出,在命令行上输入java javac出现了我们熟悉的提示
[root@localhost kevin]# java -version
java version "1.7.0_06"
Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
Java HotSpot(TM) Client VM (build 23.2-b09, mixed mode, sharing)
[root@localhost kevin]#