在Red hat linux enterprise 五 上安装 eclipse
在Red hat linux enterprise 5 上安装 eclipse(2009-04-12 11:22:47)
1.安装JDK
我的机器上安装的是jdk6.版本是jdk1.6.0_13,下载的文件是jdk-6u13-linux-i586.bin,并且配置好环境变量,详情参
考我的文章“在Red hat linux enterprise 5 上安装 JDK 6.0"
2. 下载Eclipse
我下载的是eclipse-jee-ganymede-SR2-linux-gtk.tar.gz 其是JAVA EE
eclipse,能够创建Web工程,EJB工程等企业应用相关的工程.
3.安装eclipse
将下载的eclipse-jee-ganymede-SR2-linux-gtk.tar.gz拷贝到你想安装Eclipse的目录下(我这里是/usr
/java,执行如下命令,
# tar -zxvf eclipse-jee-ganymede-SR2-linux-gtk.tar.gz
执行这个命令后你会看到在你所选择的目录下有了一个叫eclipse的文件夹,我这里是/usr/java/eclipse
在完成上面的步骤之后,你可能会认为你也大功告成了,但有可能出现的问题是当启动Eclipse时,其提示当前的JDK版本与eclipse要求的版本不
匹配,其原因是当启动Eclipse时其默认使用linux自带的jdk 如jdk
1.4.2_x等,其并没有使用我们安装的JDK1.6x.那么如何解决这个问题呢?
请看如下:
首先需要把新安装的jdk添加到alternatives
# alternatives --install /usr/bin/java java
/usr/java/jdk1.6.0_13/jre/bin/java 2
然后使用--display选项可以查看目前系统可用的JDK:
# ./alternatives --display java
确认无误后,就可以使用--config参数来选择想用的JDK了:
# ./alternatives --config java
共有 3 个程序提供“java”。
选择 命令
-----------------------------------------------
*+ 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
2 /usr/java/jdk1.6.0_13/jre/bin/java
3 /usr/java/jdk1.6.0_13/bin/java
按 Enter 来保存当前选择[+],或键入选择号码:2
这里我们输入2并按 Enter 来保存.
到此为止你以为没问题了,但当你重新启动eclispe时 ,其可能自动关闭,为什么呢?请看如下,
" Summary
SELinux is preventing /usr/java/eclipse/eclipse from loading
/usr/java/jdk1.6.0_13/jre/lib/i386/client/libjvm.so which
requires text
relocation.
Detailed Description
The /usr/java/eclipse/eclipse application attempted to load
/usr/java/jdk1.6.0_13/jre/lib/i386/client/libjvm.so which
requires text
relocation. This is a potential security problem. Most
libraries do not
need this permission. Libraries are sometimes coded incorrectly
and request
this permission. The
http://people.redhat.com/drepper/selinux-mem.html web
page explains how to remove this requirement. You can configure
SELinux
temporarily to allow
/usr/java/jdk1.6.0_13/jre/lib/i386/client/libjvm.so to
use relocation as a workaround, until the library is fixed.
Please file a
http://bugzilla.redhat.com/bugzilla/enter_bug.cgi against this
package.
Allowing Access
If you trust /usr/java/jdk1.6.0_13/jre/lib/i386/client/libjvm.so
to run
correctly, you can change the file context to textrel_shlib_t.
"chcon -t
textrel_shlib_t
/usr/java/jdk1.6.0_13/jre/lib/i386/client/libjvm.so"
The following command will allow this access:
chcon -t textrel_shlib_t
/usr/java/jdk1.6.0_13/jre/lib/i386/client/libjvm.so
Additional Information
Source Context
system_u:system_r:unconfined_t:SystemLow-
SystemHigh
Target Context system_u:object_r:usr_t
Target Objects
/usr/java/jdk1.6.0_13/jre/lib/i386/client/libjvm.s
o [ file ]
Affected RPM Packages
Policy RPM selinux-policy-2.4.6-30.el5
Selinux Enabled True
Policy Type targeted
MLS Enabled True
Enforcing Mode Enforcing
Plugin Name plugins.allow_execmod
Host Name localhost.localdomain
Platform Linux localhost.localdomain
2.6.18-8.el5xen #1 SMP
Fri Jan 26 14:42:21 EST 2007 i686 i686
Alert Count 1
Line Numbers
Raw Audit Messages
avc: denied { execmod } for comm="eclipse" dev=dm-0 egid=0 euid=0
exe="/usr/java/eclipse/eclipse" exit=-13 fsgid=0 fsuid=0 gid=0
items=0
name="libjvm.so"
path="/usr/java/jdk1.6.0_13/jre/lib/i386/client/libjvm.so"
pid=3579 scontext=system_u:system_r:unconfined_t:s0-s0:c0.c1023
sgid=0
subj=system_u:system_r:unconfined_t:s0-s0:c0.c1023 suid=0
tclass=file
tcontext=system_u:object_r:usr_t:s0 tty=(none) uid=0
"
根据这个信息提示系统建议我们使用如下命令去解决问题
#chcon -t textrel_shlib_t
/usr/java/jdk1.6.0_13/jre/lib/i386/client/libjvm.so
执行完这个命令后,重新启动eclipse,你会发现我们终于成功了.
4.为Eclipse创建一个link在桌面上.
右击图形界面——〉选择"新建启动器(New
Launcher)"——〉名称(Name)输入Eclipse——〉命令(Command)选择Eclipse解压目录/usr/java
/eclipse——〉图标(Icon)可以选择Eclipse的图标——〉点击确定完成,然后你就可以双击图形界面中的快速启动来启动你的
eclipse了,当然也可以在shell下执行eclipse根目录下的执行文件来启动eclipse!