继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

Linux——CentOS7使用yum命令安装Java SDK

song先生
关注TA
已关注
手记 41
粉丝 218
获赞 1546

安装jdk有很多种方式比如我们可以在Oracle Technology Network》Java》Java SE》Download(点此链接跳转)下载jdk-8u25-linux-x64.rpm,然后再上传到服务器进行安装,本人感觉过程比较繁琐,所以比较推荐使用yum命令安装Java SDK。


我们登录自己的服务器后输入下面一行命令查看JDK软件包的列表

yum search java | grep -i --color JDK

接下来会列出来如下信息列表

ldapjdk-javadoc.noarch : Javadoc for ldapjdk
icedtea-web.x86_64 : Additional Java components for OpenJDK - Java browser
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-headless.x86_64 : The OpenJDK runtime environment without
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.i686 : OpenJDK Runtime Environment
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
java-1.8.0-openjdk-accessibility-debug.x86_64 : OpenJDK accessibility connector
java-1.8.0-openjdk-debug.i686 : OpenJDK Runtime Environment with full debug on
java-1.8.0-openjdk-debug.x86_64 : OpenJDK Runtime Environment with full debug on
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-demo-debug.x86_64 : OpenJDK Demos with full debug on
java-1.8.0-openjdk-devel.i686 : OpenJDK Development Environment
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-devel-debug.i686 : OpenJDK Development Environment with full
java-1.8.0-openjdk-devel-debug.x86_64 : OpenJDK Development Environment with
java-1.8.0-openjdk-headless.i686 : OpenJDK Runtime Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-headless-debug.i686 : OpenJDK Runtime Environment with full
java-1.8.0-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-javadoc-debug.noarch : OpenJDK API Documentation for packages
java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK API Documentation compressed in
java-1.8.0-openjdk-javadoc-zip-debug.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk-src-debug.x86_64 : OpenJDK Source Bundle for packages with
ldapjdk.noarch : The Mozilla LDAP Java SDK
openprops.noarch : An improved java.util.Properties from OpenJDK

选择自己需要的版本进行安装,在这里我选择了java-1.8.0-openjdk-devel.x86_64进行安装。

yum install java-1.8.0-openjdk-devel.x86_64

如果输入命令后显示(如果本来就是root用户就没什么关系啦)

Loaded plugins: fastestmirror, langpacks
You need to be root to perform this command.

说明你需要获取root权限,切换到root用户

su root

接着输入root用户密码即可,现在你就拥有了root用户权限,之后再次执行命令yum install+自己所选择的JDK版本即可

在安装时到这里(见下图)会停下输入y即可继续进行安装

Install  1 Package  (+30 Dependent packages)
Upgrade             ( 10 Dependent packages)

Total download size: 48 M
Is this ok [y/d/N]: y

最后输入输入命令查看版本信息

java -version

出现以下信息,即安装成功

openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

是不是很简单呢

原创内容如需转载请注明出处http://www.imooc.com/article/16609,谢谢合作。

打开App,阅读手记
3人推荐
发表评论
随时随地看视频慕课网APP