软件版本:jdk-8u20-linux-x64.rpm
下载地址:
(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 <>/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
-classpath
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D=
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:
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[:...|:]
-enableassertions[:...|:]
enable assertions with specified granularity
-da[:...|:]
-disableassertions[:...|:]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:[=]
load native agent library , e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:[=]
load native agent library by full pathname
-javaagent:[=]
load Java programming language agent, see java.lang.instrument
-splash:
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
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 Specify where to find user class files and annotation processors
-cp Specify where to find user class files and annotation processors
-sourcepath Specify where to find input source files
-bootclasspath Override location of bootstrap class files
-extdirs Override location of installed extensions
-endorseddirs Override location of endorsed standards path
-proc:{none,only} Control whether annotation processing and/or compilation is done.
-processor [,,...] Names of the annotation processors to run; bypasses default discovery process
-processorpath Specify where to find annotation processors
-parameters Generate metadata for reflection on method parameters
-d Specify where to place generated class files
-s Specify where to place generated source files
-h Specify where to place generated native header files
-implicit:{none,class} Specify whether or not to generate class files for implicitly referenced files
-encoding Specify character encoding used by source files
-source Provide source compatibility with specified release
-target Generate class files for specific VM version
-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 Pass directly to the runtime system
-Werror Terminate compilation if warnings occur
@ Read options and filenames from file