標籤:jdk環境的安裝
軟體版本:jdk-8u20-linux-x64.rpm
:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/4B/5E/wKiom1QquCSz_d1JAAdJ-iGA1UE650.jpg" title="Java SE Development Kit 8u20.jpg" alt="wKiom1QquCSz_d1JAAdJ-iGA1UE650.jpg" />
(1)、尋找OpenJDK的包
[[email protected] ~]# rpm -qa | grep javajava-1.6.0-openjdk-1.6.0.0-1.50.1.11.5.el6_3.x86_64tzdata-java-2012j-1.el6.noarchjava_cup-0.10k-5.el6.x86_64java-1.7.0-openjdk-1.7.0.9-2.3.4.1.el6_3.x86_64java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64gcc-java-4.4.7-3.el6.x86_64
(2)、檢查OpenJDK的版本
[[email protected] ~]# java -versionjava 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)[[email protected] ~]#
(3)、卸載OpenJDK
[[email protected] ~]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.50.1.11.5.el6_3.x86_64[[email protected] ~]# rpm -e --nodeps tzdata-java-2012j-1.el6.noarch[[email protected] ~]# rpm -e --nodeps java_cup-0.10k-5.el6.x86_64[[email protected] ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.9-2.3.4.1.el6_3.x86_64[[email protected] ~]# rpm -e --nodeps java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64[[email protected] ~]# rpm -e --nodeps gcc-java-4.4.7-3.el6.x86_64
(4)、安裝jdk-8u20-linux-x64.rpm
[[email protected] 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...[[email protected] Downloads]#
(5)、配置環境變數
[[email protected] 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[[email protected] jdk1.8.0_20]#
使環境變數立即生效:
[[email protected] jdk1.8.0_20]# source /etc/profile
(6)、測試安裝是否成功
[[email protected] jdk1.8.0_20]# java[[email protected] jdk1.8.0_20]# java -version[[email protected] jdk1.8.0_20]# javac
詳情如下:
[[email protected] 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.
[[email protected] 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)
[[email protected] 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
CentOS-6.4-x86_64中安裝jdk-8u20-linux-x64