现在的位置: 首页 > 综合 > 正文

轻松解决Linux安装Eclipse方法

2013年02月03日 ⁄ 综合 ⁄ 共 6085字 ⁄ 字号 评论关闭

随着Linux的发展,很多人开始学习Linux系统,你了解Linux系统么?你是Linux系统的应用者么?本文为你详细介绍Linux安装Eclipse,为你在学习Linux安装Eclipse时起一定的作用。以下是Linux安装Eclipse完全攻略。

1. ubuntu 下安装Eclipse

1.1 在Ubuntu搭建java开发环境

(1)安装好Ubuntu系统;安装的时候强烈建议连接上网,它会自动下载语言包,自动装上五笔,拼 音,还有会默认把firefox浏览器设置为中文.

(2)配置Ubuntu环境:添加源,更新软件信息,升级内核

可以参考网上的一篇文章:

http://hi.baidu.com/myownroom/blog/category/Linux

$ sudo apt-get update

(3)安装jdk软件包

sudo apt-get install sun-java6-jdk

大约过了二十分钟会提示安装jdk成功信息,这时候你可以在shell打入java或javac看一看,看一下显示的信息有显示(这里显示的是jdk版本号,如果系统自带的有gdk,需要注意一下),证明jdk安装成功.


(正在设定 sun-java6-jre 不动了……

怎么办?\"确定\"选项明明就在,但是狂按回车没反应……

网上一查,按tab键,\"确定\"变红,再按回车,ok了)

接下来的工作是,配置JRE环境:

在shell执行:

sudo update-alternatives --config java

通常会给出两个或两个以上选择的路径

选择:/usr/lib/jvm/java-1.6.0-sun/jre/bin/java作为你的JRE

(4)建议安装安装浏览器Java插件(不是必要的):

在shell中执行:

sudo apt-get install sun-java6-plugin

1.2 在ubuntu下安装eclipse。

(1)到http://www.eclipse.org/downloads/,下载eclipse for linux版本,我下载后文件的完整名称为:

eclipse-java-galileo-SR1-linux-gtk.tar.gz

解压缩后,可以查看根目录下的

(2)将eclipse-SDK-3.2.1-linux-gtk.tar.gz这一个文件放到/opt目录下面(用root执行mv _ _语句才能移进opt文件夹)

(3)在shell中进入/opt/,执行: tar -zxvf eclipse-SDK-4.2.1-linux-gtk.tar.gz语句,解压缩下载文件

(4)在shell中,进入到eclipse 目录,cd /opt/eclipse

设置文件eclipse执行权:chown -R root:你的用户名 eclipse

(5)创建桌面连接

sudo gedit /usr/share/applications/eclipse.desktop

加入下面内容

[Desktop Entry] Encoding=UTF-8 Name=Eclipse Comment=Eclipse SDK Exec=/opt/eclipse/eclipse Icon=/opt/eclipse/icon.xpm Terminal=false Type=Application Categories=Application;Development;


这时就会在最左上角的应用程序菜单加多一个\"编程\"-->\"eclipse\"的菜单,点击即可起动eclipse.

提示:如果点击\"编程\"-->\"eclipse\"的菜单提示编码错误,就在桌面上自己建一个启动器指向eclipse安装目录即可..

参考网址:http://www.javaeye.com/topic/34636

2. Redhat 下安装Eclipse

参考:

(1)http://collonn.javaeye.com/blog/436427

(2)http://hi.baidu.com/summerytyj/blog/item/58ca9801b 4cb78d3267fb579.html

RedHat上安装jdk

第一步:如果原来机子上安装的有RedHat,需要首先卸载RedHat自带的JDK。因为版本比较新的eclipse可能需要比较新的jdk版本。

rpm -qa | grep gcj

#会列出一些东西如:java-1.4.2-gcj-compat-1.4.2.0-27jpp等,我们只删除含有java字串的软件包

rpm -e java-1.4.2-gcj-compat-1.4.2.0-27jpp

#或者:rpm -e --nodeps java 也可以:

但是这样删除的时候可能会遇到一些问题,主要是有关依赖包的问题。

这可以在Applications->Add and Remove Software中找到java开头的包进行删除。

第二步:安装jdk(无论是eclipse c/c++还是eclipse java,都需要jdk)

在sun官网上下载对应操作系统的jdk。

一般有两种格式的文件。

第三步:安装eclipse。

解压电机eclipse可执行文件即可。

第四步:在桌面上添加eclipse图标

(1)编写.sh文件

export JAVA_HOME = /usr/java/(jdk安装文件夹)

export PATH = $JAVA_HOME/bin:$PATH

CLASSPATH=.:/usr/java/j2sdk1.4.2_01/lib/tools.jar: $CLASSPATH

export CLASSPATH

opt/eclipse/eclipse(此为eclipse解压缩文件所在目录) -vm /usr/java/(jdk安装文件夹) /bin/java -data ~/workspace &


create launch from desktop:

(1)entry derectory:/usr/share/applications/

(2)gedit eclipse.destop

[Desktop Entry] Encoding=UTF-8 Name=EclipseC++ Type=Application Terminal=false Exec=/opt/eclipseC++/eclipse -vm /opt/jdk1.6.0_16/bin/java -data ~/workspaceC++ Icon=/opt/eclipseC++/icon.xpm Categories=Apllication;Development;


(2)在桌面上右键单击,选择create launcher,然后选择上述编写的.sh文件。这时,桌面上就会出现eclipse可执行文件。点击即可运行。

3. 配置tomcat

第一步:

下载eclipse tomcat插件:

http://www.eclipsetotale.com/tomcatPlugin.html

将该插件解压后放到eclipse的plugins目录下。

第二步:

下载tomcat:

http://tomcat.apache.org/

重启eclipse即可看到tomcat的图标。

4. MySQL:

download address:

http://dev.mysql.com/downloads/

access denied (java.util.PropertyPermission catalina.home read

Window->Preferences-> Tomcat

Advanced->Launch Tomcat Using Sacrity Manager(don not choose)

5. MyEclipse:

download wensite:

http://www.verycd.com/topics/2741105/

ed2k://|file|[J2EE.集成开发环境].TLF-SOFT-MyEclipse.Enterprise.Workbench.v7.1.1-R iFT.nfo|3943|1bb19755c5394a0fd8ff7592ca909d04|h=JBB AC3WAD444UT3MP2RURLNVMZXQLFEQ|/


reference:http://blog.sina.com.cn/s/blog_45fd882f0100cjsx.ht ml

have downloaded the MyEclipse , I input

$ sudo chmod 777 MyEclipse.Enterprise.Workbench.v7.1.1.LINUX.X86-Ri FT.bin

$ ./MyEclipse.Enterprise.Workbench.v7.1.1.LINUX.X86- RiFT.bin

bash: ./MyEclipse.Enterprise.Workbench.v7.1.1.LINUX.X86- RiFT.bin:无法执行二进制文件

$ sh MyEclipse.Enterprise.Workbench.v7.1.1.LINUX.X86-Ri FT.bi n

MyEclipse.Enterprise.Workbench.v7.1.1.LINUX.X86-Ri FT.bin: 1: Syntax error: \"&\" unexpected (expecting \")\")


I do not know how to solve it,the quit.

But I still can develop web applications on eclipse.

6. Start Web Development

Reference:http://cwiki.apache.org/WW/setting-up-eclipse-with -tomcat.html

(1)Help->Install new software

->Available Software

input the website: \"http://download.eclipse.org/releases/galileo\"

choose \"WEB,XML,Java EE Development\"

the plugin can help create web applications, including JavaScript, XML, XSL, XSD, HTML, XHTML, CSS, JSP, EJBs, Webservices, and JPA tools

(2)define server:

new -> server

tomcat 5.0

(It do not support for tomcat 5.5 and 6.0, so I can just use tomcat 5.0)

(3) restart the eclipse

new-> project

input:\"web\"

choose \"Dynamic Website\"

(4) add new html to \"web \" project

<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"> <html> <head> <mce:script type=\"text/javascript\"><!-- function hello(){ alert(\"hello\"); } // --></mce:script> <meta http-equiv=\"Content-Type\" content=\"text/html;
charset=UTF-8\"> <title>Insert title here</title> </head> <body> <input type=\"text\" id=\"input1\" ></input> <br></br> <input type=\"button\" value=\"submit\" onClick=\"hello()\"></input> </body> </html>

(5) 选中web工程,右键单击。

Run as -> Run on server

choose tomcat5.0

input website :\"http://localhost:8080/web/index.html\"

you will find you have got much seccess!

(6)add new servnet for the project:

new -> servlet,

name:helloservlet

import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class for Servlet: HelloServlet * */ public class helloservlet extends
javax.servlet.http.HttpServlet implements javax.servlet.Servlet { /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#HttpServlet() */ public helloservlet() { super(); } /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#doGet(HttpServletRe quest
request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.getWriter().write(\"Hello, world!\"); } /* (non-Java-doc) * @see javax.servlet.http.HttpServlet#doPost(HttpServletR
equest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub } }


restart the eclipse,and run on server,

input web site:\"http://127.0.0.1:8080/web/hellowervlet\"

you will see:

Hello, world!

这样就你学会了Linux安装Eclipse。

 

 

抱歉!评论已关闭.