在linux上使用yum安装JDK
1.查找java相关得列表
[root@localhost ~]# yum -y list java*
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
- base: mirrors.zju.edu.cn
- extras: mirrors.aliyun.com
- updates: mirrors.aliyun.com
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
Installed Packages
java-1.5.0-gcj.x86_64 1.5.0.0-29.1.el6 @base/$releasever
java-1.6.0-openjdk.x86_64 1:1.6.0.0-1.45.1.11.1.el6 @base/$releasever
java_cup.x86_64 1:0.10k-5.el6 @base/$releasever
Available Packages
java-1.5.0-gcj-devel.x86_64 1.5.0.0-29.1.el6 base
java-1.5.0-gcj-javadoc.x86_64 1.5.0.0-29.1.el6 base
java-1.5.0-gcj-src.x86_64 1.5.0.0-29.1.el6 base
java-1.6.0-openjdk.x86_64 1:1.6.0.35-1.13.7.1.el6_6 updates
java-1.6.0-openjdk-demo.x86_64 1:1.6.0.35-1.13.7.1.el6_6 updates
java-1.6.0-openjdk-devel.x86_64 1:1.6.0.35-1.13.7.1.el6_6 updates
java-1.6.0-openjdk-javadoc.x86_64 1:1.6.0.35-1.13.7.1.el6_6 updates
java-1.6.0-openjdk-src.x86_64 1:1.6.0.35-1.13.7.1.el6_6 updates
java-1.7.0-openjdk.x86_64 1:1.7.0.79-2.5.5.1.el6_6 updates
java-1.7.0-openjdk-demo.x86_64 1:1.7.0.79-2.5.5.1.el6_6 updates
java-1.7.0-openjdk-devel.x86_64 1:1.7.0.79-2.5.5.1.el6_6 updates
java-1.7.0-openjdk-javadoc.noarch 1:1.7.0.79-2.5.5.1.el6_6 updates
java-1.7.0-openjdk-src.x86_64 1:1.7.0.79-2.5.5.1.el6_6 updates
java-1.8.0-openjdk.x86_64 1:1.8.0.45-28.b13.el6_6 updates
java-1.8.0-openjdk-demo.x86_64 1:1.8.0.45-28.b13.el6_6 updates
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.45-28.b13.el6_6 updates
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.45-28.b13.el6_6 updates
java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.45-28.b13.el6_6 updates
java-1.8.0-openjdk-src.x86_64 1:1.8.0.45-28.b13.el6_6 updates
java_cup-javadoc.x86_64 1:0.10k-5.el6 base
java_cup-manual.x86_64 1:0.10k-5.el6 base
javacc.x86_64 4.1-0.5.el6 base
javacc-demo.x86_64 4.1-0.5.el6 base
javacc-manual.x86_64 4.1-0.5.el6 base
javassist.noarch 3.9.0-6.el6 base
javassist-javadoc.noarch 3.9.0-6.el6 base
2.使用root用户安装
安装时提醒必须使用root用户,sudo都不行。
[root@localhost ~]# yum -y install java-1.7.0-openjdk*
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
- base: mirrors.zju.edu.cn
- extras: mirrors.aliyun.com
- updates: mirrors.aliyun.com
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package java-1.7.0-openjdk.x86_64 1:1.7.0.79-2.5.5.1.el6_6 will be installed
–> Processing Dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit) for package: 1:java-1.7.0-openjdk-1.7.0.79-2.5.5.1.el6_6.x86_64
—> Package java-1.7.0-openjdk-demo.x86_64 1:1.7.0.79-2.5.5.1.el6_6 will be installed
—> Package java-1.7.0-openjdk-devel.x86_64 1:1.7.0.79-2.5.5.1.el6_6 will be installed
—> Package java-1.7.0-openjdk-javadoc.noarch 1:1.7.0.79-2.5.5.1.el6_6 will be installed
—> Package java-1.7.0-openjdk-src.x86_64 1:1.7.0.79-2.5.5.1.el6_6 will be installed
–> Running transaction check
—> Package libjpeg.x86_64 0:6b-46.el6 will be obsoleted
—> Package libjpeg-turbo.x86_64 0:1.2.1-3.el6_5 will be obsoleting
–> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository
Size
================================================================================
Installing:
java-1.7.0-openjdk x86_64 1:1.7.0.79-2.5.5.1.el6_6 updates 26 M
java-1.7.0-openjdk-demo x86_64 1:1.7.0.79-2.5.5.1.el6_6 updates 1.9 M
java-1.7.0-openjdk-devel x86_64 1:1.7.0.79-2.5.5.1.el6_6 updates 9.4 M
java-1.7.0-openjdk-javadoc noarch 1:1.7.0.79-2.5.5.1.el6_6 updates 16 M
java-1.7.0-openjdk-src x86_64 1:1.7.0.79-2.5.5.1.el6_6 updates 39 M
libjpeg-turbo x86_64 1.2.1-3.el6_5 base 174 k
replacing libjpeg.x86_64 6b-46.el6
Transaction Summary
Install 6 Package(s)
Total download size: 92 M
Downloading Packages:
(1/6): java-1.7.0-openjdk-1.7.0.79-2.5.5.1.el6_6.x86_64. | 26 MB 02:44
(2/6): java-1.7.0-openjdk-demo-1.7.0.79-2.5.5.1.el6_6.x8 | 1.9 MB 00:10
(3/6): java-1.7.0-openjdk-devel-1.7.0.79-2.5.5.1.el6_6.x | 9.4 MB 01:23
(4/6): java-1.7.0-openjdk-javadoc-1.7.0.79-2.5.5.1.el6_6 | 16 MB 02:16
(5/6): java-1.7.0-openjdk-src-1.7.0.79-2.5.5.1.el6_6.x86 | 39 MB 04:23
(6/6): libjpeg-turbo-1.2.1-3.el6_5.x86_64.rpm | 174 kB 00:00
Total 143 kB/s | 92 MB 11:03
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) [email protected]
Package: centos-release-6-3.el6.centos.9.x86_64 (@base/$releasever)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : libjpeg-turbo-1.2.1-3.el6_5.x86_64 1/7
Installing : 1:java-1.7.0-openjdk-1.7.0.79-2.5.5.1.el6_6.x86_64 2/7
Installing : 1:java-1.7.0-openjdk-src-1.7.0.79-2.5.5.1.el6_6.x86_64 3/7
Installing : 1:java-1.7.0-openjdk-demo-1.7.0.79-2.5.5.1.el6_6.x86_64 4/7
Installing : 1:java-1.7.0-openjdk-devel-1.7.0.79-2.5.5.1.el6_6.x86_64 5/7
Installing : 1:java-1.7.0-openjdk-javadoc-1.7.0.79-2.5.5.1.el6_6.noarch 6/7
Erasing : libjpeg-6b-46.el6.x86_64 7/7
Verifying : 1:java-1.7.0-openjdk-src-1.7.0.79-2.5.5.1.el6_6.x86_64 1/7
Verifying : 1:java-1.7.0-openjdk-1.7.0.79-2.5.5.1.el6_6.x86_64 2/7
Verifying : 1:java-1.7.0-openjdk-javadoc-1.7.0.79-2.5.5.1.el6_6.noarch 3/7
Verifying : 1:java-1.7.0-openjdk-demo-1.7.0.79-2.5.5.1.el6_6.x86_64 4/7
Verifying : 1:java-1.7.0-openjdk-devel-1.7.0.79-2.5.5.1.el6_6.x86_64 5/7
Verifying : libjpeg-turbo-1.2.1-3.el6_5.x86_64 6/7
Verifying : libjpeg-6b-46.el6.x86_64 7/7
Installed:
java-1.7.0-openjdk.x86_64 1:1.7.0.79-2.5.5.1.el6_6
java-1.7.0-openjdk-demo.x86_64 1:1.7.0.79-2.5.5.1.el6_6
java-1.7.0-openjdk-devel.x86_64 1:1.7.0.79-2.5.5.1.el6_6
java-1.7.0-openjdk-javadoc.noarch 1:1.7.0.79-2.5.5.1.el6_6
java-1.7.0-openjdk-src.x86_64 1:1.7.0.79-2.5.5.1.el6_6
libjpeg-turbo.x86_64 0:1.2.1-3.el6_5
Replaced:
libjpeg.x86_64 0:6b-46.el6
Complete!
3.确认是否安装成功
[root@localhost ~]# java -version
java version “1.7.0_79”
OpenJDK Runtime Environment (rhel-2.5.5.1.el6_6-x86_64 u79-b14)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
[root@localhost ~]# 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
-d Specify where to place generated class files
-s Specify where to place generated source 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
-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
[root@localhost ~]# java
Usage: java [-options] class [args…]
(to execute a class)
or java [-options] -jar jarfile [args…]
(to execute a jar file)
where options include:
load Java programming language agent, see java.lang.instrument
-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.
4.默认情况下jdk安装得路径
/usr/lib/jvm
由于我们得机器可能同时安装好几个版本得jdk,所以在/etc/alternatives目录下会有一个java链接到具体的java命令。而这个/etc/alternatives/java会被/usr/bin/java链接。从而java命令就被设置到了shell环境中。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。