在linux上使用yum安装JDK

1.查找java相关得列表

[qyf@localhost ~]$ yum -y list java*

执行结果

  1. [qyf@localhost ~]$ yum -y list java*

  2. Loaded plugins: fastestmirror

  3. base | 1.1 kB 00:00

  4. base/primary | 995 kB 00:00

  5. base 2789/2789

  6. extras | 2.1 kB 00:00

  7. extras/primary_db | 164 kB 00:20

  8. updates | 1.9 kB 00:00

  9. updates/primary_db | 422 kB 00:01

  10. Available Packages

  11. java-1.4.2-gcj-compat.i386 1.4.2.0-40jpp.115 base

  12. java-1.4.2-gcj-compat-devel.i386 1.4.2.0-40jpp.115 base

  13. java-1.4.2-gcj-compat-javadoc.i386 1.4.2.0-40jpp.115 base

  14. java-1.4.2-gcj-compat-src.i386 1.4.2.0-40jpp.115 base

  15. java-1.6.0-openjdk.i386 1:1.6.0.0-5.1.13.3.el5_10 updates

  16. java-1.6.0-openjdk-demo.i386 1:1.6.0.0-5.1.13.3.el5_10 updates

  17. java-1.6.0-openjdk-devel.i386 1:1.6.0.0-5.1.13.3.el5_10 updates

  18. java-1.6.0-openjdk-javadoc.i386 1:1.6.0.0-5.1.13.3.el5_10 updates

  19. java-1.6.0-openjdk-src.i386 1:1.6.0.0-5.1.13.3.el5_10 updates

  20. java-1.7.0-openjdk.i386 1:1.7.0.55-2.4.7.1.el5_10 updates

  21. java-1.7.0-openjdk-demo.i386 1:1.7.0.55-2.4.7.1.el5_10 updates

  22. java-1.7.0-openjdk-devel.i386 1:1.7.0.55-2.4.7.1.el5_10 updates

  23. java-1.7.0-openjdk-javadoc.i386 1:1.7.0.55-2.4.7.1.el5_10 updates

  24. java-1.7.0-openjdk-src.i386 1:1.7.0.55-2.4.7.1.el5_10 updates

  25. java_cup.i386 1:0.10-0.k.6jpp.1 base

  26. java_cup-javadoc.i386 1:0.10-0.k.6jpp.1 base

  27. java_cup-manual.i386 1:0.10-0.k.6jpp.1 base

  28. javacc.i386 4.0-3jpp.3 base

  29. javacc-demo.i386 4.0-3jpp.3 base

  30. javacc-manual.i386 4.0-3jpp.3 base


2.使用root用户安装
安装时提醒必须使用root用户,sudo都不行。

[qyf@localhost ~]$ yum -y install java-1.6.0-openjdk*

执行结果

  1. [qyf@localhost ~]$ yum -y install java-1.6.0-openjdk*

  2. Loaded plugins: fastestmirror

  3. Loading mirror speeds from cached hostfile

  4. * base: mirror.bit.edu.cn

  5. * extras: mirror.bit.edu.cn

  6. * updates: centos.ustc.edu.cn

  7. base | 1.1 kB 00:00

  8. base/primary | 995 kB 00:07

  9. base 2789/2789

  10. extras | 2.1 kB 00:00

  11. extras/primary_db | 164 kB 00:02

  12. updates | 1.9 kB 00:00

  13. updates/primary_db | 422 kB 00:07

  14. Setting up Install Process

  15. Resolving Dependencies

  16. --> Running transaction check

  17. ---> Package java-1.6.0-openjdk.i386 1:1.6.0.0-5.1.13.3.el5_10 set to be updated

  18. --> Processing Dependency: jpackage-utils >= 1.7.3-1jpp.2 for package: java-1.6.0-openjdk

  19. --> Processing Dependency: libgif.so.4 for package: java-1.6.0-openjdk

  20. --> Processing Dependency: tzdata-java for package: java-1.6.0-openjdk

  21. ---> Package java-1.6.0-openjdk-demo.i386 1:1.6.0.0-5.1.13.3.el5_10 set to be updated

  22. ---> Package java-1.6.0-openjdk-devel.i386 1:1.6.0.0-5.1.13.3.el5_10 set to be updated

  23. ---> Package java-1.6.0-openjdk-javadoc.i386 1:1.6.0.0-5.1.13.3.el5_10 set to be updated

  24. ---> Package java-1.6.0-openjdk-src.i386 1:1.6.0.0-5.1.13.3.el5_10 set to be updated

  25. --> Running transaction check

  26. ---> Package giflib.i386 0:4.1.3-7.3.3.el5 set to be updated

  27. ---> Package jpackage-utils.noarch 0:1.7.3-1jpp.3.el5 set to be updated

  28. ---> Package tzdata-java.i386 0:2014b-1.el5 set to be updated

  29. --> Finished Dependency Resolution


  30. Dependencies Resolved


  31. ================================================================================

  32. Package Arch Version Repository

  33. Size

  34. ================================================================================

  35. Installing:

  36. java-1.6.0-openjdk i386 1:1.6.0.0-5.1.13.3.el5_10 updates 44 M

  37. java-1.6.0-openjdk-demo i386 1:1.6.0.0-5.1.13.3.el5_10 updates 2.2 M

  38. java-1.6.0-openjdk-devel i386 1:1.6.0.0-5.1.13.3.el5_10 updates 15 M

  39. java-1.6.0-openjdk-javadoc i386 1:1.6.0.0-5.1.13.3.el5_10 updates 20 M

  40. java-1.6.0-openjdk-src i386 1:1.6.0.0-5.1.13.3.el5_10 updates 39 M

  41. Installing for dependencies:

  42. giflib i386 4.1.3-7.3.3.el5 base 39 k

  43. jpackage-utils noarch 1.7.3-1jpp.3.el5 base 60 k

  44. tzdata-java i386 2014b-1.el5 updates 172 k


  45. Transaction Summary

  46. ================================================================================

  47. Install 8 Package(s)

  48. Upgrade 0 Package(s)


  49. Total download size: 120 M

  50. Downloading Packages:

  51. (1/8): giflib-4.1.3-7.3.3.el5.i386.rpm | 39 kB 00:00

  52. (2/8): jpackage-utils-1.7.3-1jpp.3.el5.noarch.rpm | 60 kB 00:00

  53. (3/8): tzdata-java-2014b-1.el5.i386.rpm | 172 kB 00:04

  54. (4/8): java-1.6.0-openjdk-demo-1.6.0.0-5.1.13.3.el5_10.i386.rpm | 2.2 MB 00:47

  55. (5/8): java-1.6.0-openjdk-devel-1.6.0.0-5.1.13.3.el5_10.i386.rpm | 15 MB 04:25

  56. (6/8): java-1.6.0-openjdk-javadoc-1.6.0.0-5.1.13.3.el5_10.i386.rpm (17%) 19% [============ ] 81 kB/s | 3.8 MB 03:19 ETA

最后一行就是在下载jdk了,这里我们安装jdk1.6相关得全部包。

3.确认是否安装成功
[qyf@localhost ~]$ java -version

执行结果

  1. [qyf@localhost ~]$ java -version

  2. java version "1.6.0_30"

  3. OpenJDK Runtime Environment (IcedTea6 1.13.3) (rhel-5.1.13.3.el5_10-i386)

  4. OpenJDK Client VM (build 23.25-b01, mixed mode)

正确显示了jdk版本信息就说明安装成功了。

4.默认情况下jdk安装得路径



/usr/lib/jvm

由于我们得机器可能同时安装好几个版本得jdk,所以在/etc/alternatives目录下会有一个java链接到具体的java命令。而这个/etc/alternatives/java会被/usr/bin/java链接。从而java命令就被设置到了shell环境中。


你可能感兴趣的:(java,linux,primary)