首页 > 系统 > Linux >

Linux 安装jdk

2017-06-20

Linux 安装jdk,1 下载JAVA JDK,2 下载完后将安装文件移到或copy到 usr java 下。

1.下载JAVA JDK
我这下载的jdk版本是 jdk-8u131-linux-x64.rpm
2. 下载完后将安装文件移到或copy到/usr/java/ 下
eg:mv jdk-8u131-linux-x64.rpm /usr/java

 [huangyan@bogon Downloads]$ ls
        jdk-8u131-linux-x64.rpm  jdk-8u131-linux-x64.tar.gz
    [huangyan@bogon Downloads]$ cp jdk-8u131-linux-x64.rpm /usr/java/
        cp: cannot create regular file ‘/usr/java/jdk-8u131-linux-x64.rpm’: Permission denied
    [huangyan@bogon Downloads]$ su root
    Password: 
    [root@bogon Downloads]# cp jdk-8u131-linux-x64.rpm /usr/java/
3.
[root@bogon java]# ls
    jdk-8u131-linux-x64.rpm
[root@bogon java]# chmod +x jdk-8u131-linux-x64.rpm 
[root@bogon java]# rpm -ivh jdk-8u131-linux-x64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk1.8.0_131-2000:1.8.0_131-fcs  ################################# [100%]
Unpacking JAR files...
    tools.jar...
    plugin.jar...
    javaws.jar...
    deploy.jar...
    rt.jar...
    jsse.jar...
    charsets.jar...
    localedata.jar...
[root@bogon java]# ls
default  jdk1.8.0_131  jdk-8u131-linux-x64.rpm  latest
安装完jdk 出现以上之后,要将jdk配置到系充 [root@bogon /]# vi etc/profile 加上以下内容:
export JAVA_HOME=/usr/java/jdk1.8.0_131
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

以上上内容后:
[root@bogon java]# source /etc/profile
[root@bogon java]# java -version
openjdk version “1.8.0_65”

5.发现在还是以前的版本,解决办法

export JAVA_HOME=/usr/java/jdk1.8.0_131
export JAVA_BIN=/usr/java/jdk1.8.0_131
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH

将前面的加上的改成以上就ok了

[root@bogon java]# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
[root@bogon java]# echo $PATH
/usr/java/jdk1.8.0_131/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/huangyan/.local/bin:/home/huangyan/bin:/bin:/bin:/usr/java/jdk1.8.0_131/bin
[root@bogon java]# 
相关文章
最新文章
热点推荐