rpm安装java

jdk7下载地址 http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

第一步:查看当前用户对rpm的权限
[root@localhost software]#  ls -l jdk-7u79-linux-x64.rpm
-rw-r--r--. 1 root root 138082565 Jul 23 00:29 jdk-7u79-linux-x64.rpm
第二步:添加执行权限
[root@localhost software]# chmod 755 jdk-7u79-linux-x64.rpm
[root@localhost software]#  ls -l jdk-7u79-linux-x64.rpm
-rwxr-xr-x. 1 root root 138082565 Jul 23 00:29 jdk-7u79-linux-x64.rpm
第三步:使用rpm命令进行安装
[root@localhost software]# rpm -ivh jdk-7u79-linux-x64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk-2000:1.7.0_79-fcs            ################################# [100%]
Unpacking JAR files...
    rt.jar...
    jsse.jar...
    charsets.jar...
    tools.jar...
    localedata.jar...
    jfxrt.jar...
第四步:java -version查看是否成功
[root@localhost software]# java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
第五步:查看java安装位置
[root@localhost jdk1.7.0_79]# find / -name java
find: ?.run/user/1000/gvfs?. Permission denied
/etc/pki/ca-trust/extracted/java
/etc/pki/java
/usr/bin/java
/usr/java
/usr/java/jdk1.7.0_79/bin/java
/usr/java/jdk1.7.0_79/jre/bin/java
第六步:写个Hello进行测试
[root@localhost jdk1.7.0_79]# ls
[root@localhost jdk1.7.0_79]# vi Hello.java
public class Hello{
        public static void main(String[] args ){
                System.out.println("test");
        }

}
[root@localhost jdk1.7.0_79]# vi Hello.java
public class Hello{
        public static void main(String[] args ){
                System.out.println("test");
        }

}
[root@localhost jdk1.7.0_79]# javac Hello.java
[root@localhost jdk1.7.0_79]# java Hello
test

 

 

注意:

上面安装并没有修改ect/profile文件,添加环境变量就可以执行,但为了后续tomcat等软件安装建议设置环境变量

修改/etc/profile文件,在最后加上以下信息:
JAVA_HOME=/usr/java/jdk1.7.0_79
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME PATH CLASSPATH
保存后推出
source /etc/profile

 

 客户公司配置

export JAVA_HOME=/usr/java/jdk1.7.0_15
export CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$PATH:$JAVA_HOME/bin
export JRE_HOME=$JAVA_HOME/jre

你可能感兴趣的:(linux)