ECLIPSE 使用初步
1 集成lomboz和tomcat
网上有很多文章,不再赘诉,只要把相应的插件下载后解压,拷贝到eclipse对应的目录即可.如果安装正确将在工具栏上有相应的图标(如图).

2 创建工程
FILE->NEW->PROJECT

选择Java Project,Next

填写工程名称,选择分开的源文件和输出文件.Next->Finish.
右击src文件夹,新建一个package,名称为world

工程结构可以在导航栏中看到(如图)

右击world,新建一个class,名称为Helloworld

选择菜单project,选择Build Automatically,保存后可以看到在bin文件夹里出现相应的class文件.
在main方法中增加如下内容:
int testValue = 0;
System.out.println("Hello World");
testValue = testValue + 2;
System.out.println("testValue:" + testValue);
菜单run->run…

双击Configuration里的Java Application.点击Run按钮.可以看到Console里的输出如下:

3.断点测试
双击第一句话左侧,或者右击选择Toggle Breakpoint.添加断点.然后选择Debug.可以按F6逐步调试,可以观察testValue的值,和看到Console的输出.
4.Junit的使用
首先我们给Hello类添加一个abs()方法,作用是返回绝对值
public int abs(int n){
return n>0?n:(-n);
}
选中HelloWorld.java,右键点击,选择New->JUnit Test Case:
Eclipse在询问是否添加junit.jar包之后,确定后新建一个HelloworldTest类,用来测试Helloworld类。
选中setUp()和tearDown(),然后点击“Next”:

选择要测试的方法,在前面打勾.

再在HelloWorldtest中添加测试代码:

点击Run as Junit,左侧导航栏切换到Junit.如果测试通过,将为绿色显示.
5.添加tomcat应用程序

按照向导完成即可.可以看到在server.xml中增加了如下内容:
<Context path="/testApp" reloadable="true" docBase="D:\eclipse\workspace\testApp" workDir="D:\eclipse\workspace\testApp\work\org\apache\jsp" />
如果右击src添加包和类的话,保存后会自动添加到classes中.
右击testApp新建文件index.jsp,添加如下内容:
<%@ page contentType="text/html;charset=GBK"%>
<html>
<head>
<title>
Helloworld
</title>
</head>
<body>
Helloworld!
</body>
</html>
然后启动tomcat,在浏览器中输入http://127.0.0.1:8080/testApp/index.jsp,即可看到index的内容了.
如何创建JAR包:
右击工程,导出成JAR