Linux - ubunto - install elipse for Java

1.1 在ubuntu下安装eclipse。
(1)到http://www.eclipse.org/downloads/,下载eclipse for linux版本,我下载后文件的完整名称为:
eclipse-java-2021-06-R-linux-gtk-x86_64.tar
解压缩后,可以查看根目录下的
(2)将eclipse-java-2021-06-R-linux-gtk-x86_64.tar这一个文件放到/opt目录下面(用root执行mv 语句才能移进opt文件夹)
(3)在shell中进入/opt/,执行: tar -zxvf eclipse-java-2021-06-R-linux-gtk-x86_64.tar 语句,解压缩下载文件
(4)在shell中,进入到eclipse 目录,cd /opt/eclipse

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

(5)创建桌面连接
sudo vi /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 

直接双击eclipse.desktop 可能20.04 不支持,需要右键属性,设置启动应用为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)

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。

posted @ 2021-07-18 09:11  Hai-Zhong  阅读(61)  评论(0)    收藏  举报