主页 > 六六互联 > Linux/centos的VPS上如何YUM安装Java和JDK环境?怎么用yum安装jdk?

Linux/centos的VPS上如何YUM安装Java和JDK环境?怎么用yum安装jdk?

2015年1月4日 没有评论

Linux/centos的VPS上如何YUM安装Java和JDK环境?怎么用yum安装jdk?
外贸仿牌主机,荷兰仿牌VPS,荷兰仿牌空间 发表时间:2012-03-23

有些客户需要在VPS安装java/jdk6,但是一个一个下载和编译安装十分话时间,那么,Linux/centos如何YUM安装Java和JDK环境?

首先,我们来看看yum库是否有java安装包

[root@233797 www.ctohome.com]yum -y list java*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.grikare.com
* extras: centos.mirror.facebook.net
* rpmforge: ftp-stud.fht-esslingen.de
* updates: mirror.grikare.com
Excluding Packages in global exclude list
Finished
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-1.23.1.9.10.el5_7 updates
java-1.6.0-openjdk-demo.i386 1:1.6.0.0-1.23.1.9.10.el5_7 updates
java-1.6.0-openjdk-devel.i386 1:1.6.0.0-1.23.1.9.10.el5_7 updates
java-1.6.0-openjdk-javadoc.i386 1:1.6.0.0-1.23.1.9.10.el5_7 updates
java-1.6.0-openjdk-src.i386 1:1.6.0.0-1.23.1.9.10.el5_7 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

然后我们安装java1.6.x,怎样使用yum安装java? 怎么用yum安装jdk?

[root@233797 www.ctohome.com]yum -y install java-1.6.0-openjdk*

查看yum安装java的结果,安装完成后,执行java -version

[root@233797 www.ctohome.com]java -version
java version “1.6.0_20″
OpenJDK Runtime Environment (IcedTea6 1.9.10) (rhel-1.23.1.9.10.el5_7-i386)
OpenJDK Client VM (build 19.0-b09, mixed mode)

执行java的时候,遇到错误:

Could not reserve enough space for object heap

Could not create the Java virtual machine.

解决办法:

在ssh下用root执行

export _JAVA_OPTIONS=”-Xms32m -Xmx64m -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:NewSize=10m -XX:MaxNewSize=10m -XX:SurvivorRatio=6 -XX:TargetSurvivorRatio=80 -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled”

还有错误的话,请参考

http://forums.vpslink.com/linux/1327-java-could-not-reserve-enough-space-object-heap.html

http://forum.openvz.org/index.php?t=msg&goto=7061

Tags: centos Linux

评论已关闭.