CentOS-6.4-x86_64中安装jdk-8u20-linux-x64



软件版本:jdk-8u20-linux-x64.rpm

下载地址:

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html




(1)、查找OpenJDK的包

[root@RHEL64 ~]# rpm -qa | grep java
java-1.6.0-openjdk-1.6.0.0-1.50.1.11.5.el6_3.x86_64
tzdata-java-2012j-1.el6.noarch
java_cup-0.10k-5.el6.x86_64
java-1.7.0-openjdk-1.7.0.9-2.3.4.1.el6_3.x86_64
java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
gcc-java-4.4.7-3.el6.x86_64


(2)、检查OpenJDK的版本

[root@RHEL64 ~]# java -version
java version "1.7.0_09-icedtea"
OpenJDK Runtime Environment (rhel-2.3.4.1.el6_3-x86_64)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)
[root@RHEL64 ~]#

 

(3)、卸载OpenJDK

[root@RHEL64 ~]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.50.1.11.5.el6_3.x86_64
[root@RHEL64 ~]# rpm -e --nodeps tzdata-java-2012j-1.el6.noarch
[root@RHEL64 ~]# rpm -e --nodeps java_cup-0.10k-5.el6.x86_64
[root@RHEL64 ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.9-2.3.4.1.el6_3.x86_64
[root@RHEL64 ~]# rpm -e --nodeps java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
[root@RHEL64 ~]# rpm -e --nodeps gcc-java-4.4.7-3.el6.x86_64


(4)、安装jdk-8u20-linux-x64.rpm

[root@RHEL64 Downloads]# rpm -ivh jdk-8u20-linux-x64.rpm 
Preparing...                ########################################### [100%]
   1:jdk1.8.0_20            ########################################### [100%]
Unpacking JAR files...
        rt.jar...
        jsse.jar...
        charsets.jar...
        tools.jar...
        localedata.jar...
        jfxrt.jar...
[root@RHEL64 Downloads]#


(5)、配置环境变量

[root@RHEL64 jdk1.8.0_20]# cat << EOF >>/etc/profile
> JAVA_HOME=/usr/java/jdk1.8.0_20
> JRE_HOME=/usr/java/jdk1.8.0_20/jre
> PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
> CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
> export JAVA_HOME JRE_HOME PATH CLASSPATH
> EOF
[root@RHEL64 jdk1.8.0_20]#

使环境变量立即生效:

[root@RHEL64 jdk1.8.0_20]# source /etc/profile


(6)、测试安装是否成功

[root@RHEL64 jdk1.8.0_20]# java
[root@RHEL64 jdk1.8.0_20]# java -version
[root@RHEL64 jdk1.8.0_20]# javac


详情如下:

[root@RHEL64 jdk1.8.0_20]# java

Usage: java [-options] class [args...]

           (to execute a class)

   or  java [-options] -jar jarfile [args...]

           (to execute a jar file)

where options include:

    -d32          use a 32-bit data model if available

    -d64          use a 64-bit data model if available

    -server       to select the "server" VM

                  The default VM is server.


    -cp <class search path of directories and zip/jar files>

    -classpath <class search path of directories and zip/jar files>

                  A : separated list of directories, JAR archives,

                  and ZIP archives to search for class files.

    -D<name>=<value>

                  set a system property

    -verbose:[class|gc|jni]

                  enable verbose output

    -version      print product version and exit

    -version:<value>

                  require the specified version to run

    -showversion  print product version and continue

    -jre-restrict-search | -no-jre-restrict-search

                  include/exclude user private JREs in the version search

    -? -help      print this help message

    -X            print help on non-standard options

    -ea[:<packagename>...|:<classname>]

    -enableassertions[:<packagename>...|:<classname>]

                  enable assertions with specified granularity

    -da[:<packagename>...|:<classname>]

    -disableassertions[:<packagename>...|:<classname>]

                  disable assertions with specified granularity

    -esa | -enablesystemassertions

                  enable system assertions

    -dsa | -disablesystemassertions

                  disable system assertions

    -agentlib:<libname>[=<options>]

                  load native agent library <libname>, e.g. -agentlib:hprof

                  see also, -agentlib:jdwp=help and -agentlib:hprof=help

    -agentpath:<pathname>[=<options>]

                  load native agent library by full pathname

    -javaagent:<jarpath>[=<options>]

                  load Java programming language agent, see java.lang.instrument

    -splash:<imagepath>

                  show splash screen with specified image

See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.


[root@RHEL64 jdk1.8.0_20]# java -version

java version "1.8.0_20"

Java(TM) SE Runtime Environment (build 1.8.0_20-b26)

Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)



[root@RHEL64 jdk1.8.0_20]# javac

Usage: javac <options> <source files>

where possible options include:

  -g                         Generate all debugging info

  -g:none                    Generate no debugging info

  -g:{lines,vars,source}     Generate only some debugging info

  -nowarn                    Generate no warnings

  -verbose                   Output messages about what the compiler is doing

  -deprecation               Output source locations where deprecated APIs are used

  -classpath <path>          Specify where to find user class files and annotation processors

  -cp <path>                 Specify where to find user class files and annotation processors

  -sourcepath <path>         Specify where to find input source files

  -bootclasspath <path>      Override location of bootstrap class files

  -extdirs <dirs>            Override location of installed extensions

  -endorseddirs <dirs>       Override location of endorsed standards path

  -proc:{none,only}          Control whether annotation processing and/or compilation is done.

  -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process

  -processorpath <path>      Specify where to find annotation processors

  -parameters                Generate metadata for reflection on method parameters

  -d <directory>             Specify where to place generated class files

  -s <directory>             Specify where to place generated source files

  -h <directory>             Specify where to place generated native header files

  -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files

  -encoding <encoding>       Specify character encoding used by source files

  -source <release>          Provide source compatibility with specified release

  -target <release>          Generate class files for specific VM version

  -profile <profile>         Check that API used is available in the specified profile

  -version                   Version information

  -help                      Print a synopsis of standard options

  -Akey[=value]              Options to pass to annotation processors

  -X                         Print a synopsis of nonstandard options

  -J<flag>                   Pass <flag> directly to the runtime system

  -Werror                    Terminate compilation if warnings occur

  @<filename>                Read options and filenames from file



本文出自 “Jerry” 博客,请务必保留此出处http://alipay.blog.51cto.com/7119970/1560188

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。