微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

centos下yum安装jdk

1.查找java相关得列表
[qyf@localhost ~]$ yum -y list java* 执行结果 [qyf@localhost ~]$ yum -y list java* Loaded plugins: fastestmirror base | 1.1 kB 00:00 base/primary | 995 kB 00:00 base 2789/2789 extras | 2.1 kB 00:00 extras/primary_db | 164 kB 00:20 updates | 1.9 kB 00:00 updates/primary_db | 422 kB 00:01 Available Packages java-1.4.2-gcj-compat.i386 1.4.2.0-40jpp.115 base java-1.4.2-gcj-compat-devel.i386 1.4.2.0-40jpp.115 base java-1.4.2-gcj-compat-javadoc.i386 1.4.2.0-40jpp.115 base java-1.4.2-gcj-compat-src.i386 1.4.2.0-40jpp.115 base java-1.6.0-openjdk.i386 1:1.6.0.0-5.1.13.3.el5_10 updates java-1.6.0-openjdk-demo.i386 1:1.6.0.0-5.1.13.3.el5_10 updates java-1.6.0-openjdk-devel.i386 1:1.6.0.0-5.1.13.3.el5_10 updates java-1.6.0-openjdk-javadoc.i386 1:1.6.0.0-5.1.13.3.el5_10 updates java-1.6.0-openjdk-src.i386 1:1.6.0.0-5.1.13.3.el5_10 updates java-1.7.0-openjdk.i386 1:1.7.0.55-2.4.7.1.el5_10 updates java-1.7.0-openjdk-demo.i386 1:1.7.0.55-2.4.7.1.el5_10 updates java-1.7.0-openjdk-devel.i386 1:1.7.0.55-2.4.7.1.el5_10 updates java-1.7.0-openjdk-javadoc.i386 1:1.7.0.55-2.4.7.1.el5_10 updates java-1.7.0-openjdk-src.i386 1:1.7.0.55-2.4.7.1.el5_10 updates java_cup.i386 1:0.10-0.k.6jpp.1 base java_cup-javadoc.i386 1:0.10-0.k.6jpp.1 base java_cup-manual.i386 1:0.10-0.k.6jpp.1 base javacc.i386 4.0-3jpp.3 base javacc-demo.i386 4.0-3jpp.3 base javacc-manual.i386 4.0-3jpp.3 base 2.使用root用户安装 安装时提醒必须使用root用户,sudo都不行。 [qyf@localhost ~]$ yum -y install java-1.7.0-openjdk* 执行结果 [root@mobilesql ~]# yum -y install java-1.7.0-openjdk* Loaded plugins: fastestmirror,rhnplugin Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Repository contrib is listed more than once in the configuration Repository base is listed more than once in the configuration Repository updates is listed more than once in the configuration Repository addons is listed more than once in the configuration Repository extras is listed more than once in the configuration Repository centosplus is listed more than once in the configuration Repository epel is listed more than once in the configuration Repository epel-debuginfo is listed more than once in the configuration This system is not registered with RHN. RHN support will be disabled. Loading mirror speeds from cached hostfile * addons: centos.ustc.edu.cn * base: mirrors.aliyun.com * epel: mirrors.neusoft.edu.cn * extras: centos.ustc.edu.cn * updates: centos.ustc.edu.cn http://yum.centos56.com/centos/5.6/sec/x86_64/repodata/repomd.xml: [Errno 4] IOError: <urlopen error (111,'Connection refused')> Trying other mirror. Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package java-1.7.0-openjdk.x86_64 1:1.7.0.111-2.6.7.1.el5_11 set to be updated --> Processing Dependency: libXcomposite.so.1()(64bit) for package: java-1.7.0-openjdk ---> Package java-1.7.0-openjdk-demo.x86_64 1:1.7.0.111-2.6.7.1.el5_11 set to be updated ---> Package java-1.7.0-openjdk-devel.x86_64 1:1.7.0.111-2.6.7.1.el5_11 set to be updated ---> Package java-1.7.0-openjdk-javadoc.x86_64 1:1.7.0.111-2.6.7.1.el5_11 set to be updated ---> Package java-1.7.0-openjdk-src.x86_64 1:1.7.0.111-2.6.7.1.el5_11 set to be updated --> Running transaction check ---> Package libXcomposite.x86_64 0:0.3-5.1 set to be updated --> Finished Dependency Resolution Dependencies Resolved ======================================================================================== Package Arch Version Repository Size ======================================================================================== Installing: java-1.7.0-openjdk-demo x86_64 1:1.7.0.111-2.6.7.1.el5_11 updates 2.4 M java-1.7.0-openjdk-devel x86_64 1:1.7.0.111-2.6.7.1.el5_11 updates 12 M java-1.7.0-openjdk-javadoc x86_64 1:1.7.0.111-2.6.7.1.el5_11 updates 21 M java-1.7.0-openjdk-src x86_64 1:1.7.0.111-2.6.7.1.el5_11 updates 40 M Updating: java-1.7.0-openjdk x86_64 1:1.7.0.111-2.6.7.1.el5_11 updates 39 M Installing for dependencies: libXcomposite x86_64 0.3-5.1 base 12 k Transaction Summary ======================================================================================== Install 5 Package(s) Upgrade 1 Package(s) Total download size: 115 M Downloading Packages: (1/6): libXcomposite-0.3-5.1.x86_64.rpm | 12 kB 00:00 (2/6): java-1.7.0-openjdk-demo-1.7.0.111-2.6.7.1.el5_11.x86_64.r | 2.4 MB 00:04 (3/6): java-1.7.0-openjdk-devel-1.7.0.111-2.6.7.1.el5_11.x86_64. | 12 MB 00:23 (4/6): java-1.7.0-openjdk-javadoc-1.7.0.111-2.6.7.1.el5_11.x86_6 | 21 MB 00:45 (5/6): java-1.7.0-openjdk-1.7.0.111-2.6.7.1.el5_11.x86_64.rpm | 39 MB 01:15 (6/6): java-1.7.0-openjdk-src-1.7.0.111-2.6.7.1.el5_11.x86_64.rp | 40 MB 01:13 ---------------------------------------------------------------------------------------- Total 524 kB/s | 115 MB 03:45 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : libXcomposite 1/7 Installing : java-1.7.0-openjdk-javadoc 2/7 Updating : java-1.7.0-openjdk 3/7 Installing : java-1.7.0-openjdk-devel 4/7 Installing : java-1.7.0-openjdk-demo 5/7 Installing : java-1.7.0-openjdk-src 6/7 Cleanup : java-1.7.0-openjdk 7/7 Installed: java-1.7.0-openjdk-demo.x86_64 1:1.7.0.111-2.6.7.1.el5_11 java-1.7.0-openjdk-devel.x86_64 1:1.7.0.111-2.6.7.1.el5_11 java-1.7.0-openjdk-javadoc.x86_64 1:1.7.0.111-2.6.7.1.el5_11 java-1.7.0-openjdk-src.x86_64 1:1.7.0.111-2.6.7.1.el5_11 Dependency Installed: libXcomposite.x86_64 0:0.3-5.1 Updated: java-1.7.0-openjdk.x86_64 1:1.7.0.111-2.6.7.1.el5_11 Complete! 3.确认是否安装成功 [qyf@localhost ~]$ java -version 执行结果 java version "1.7.0_111" OpenJDK Runtime Environment (rhel-2.6.7.1.el5_11-x86_64 u111-b01) OpenJDK 64-Bit Server VM (build 24.111-b01,mixed mode) 正确显示了jdk版本信息就说明安装成功了。 4.认情况下jdk安装得路径 /usr/lib/jvm 由于我们得机器可能同时安装好几个版本得jdk,所以在/etc/alternatives目录下会有一个java链接到具体的java命令。而这个/etc/alternatives/java会被/usr/bin/java链接。从而java命令就被设置到了shell环境中。

原文地址:https://www.jb51.cc/centos/381376.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。