2012年1月27日星期五

Renaming, and Moving Files In Eclipse



Moving and Renaming Files and Folders

Using the Eclipse menu you can rename and move source controlled files using the Refactor command. To move a file into a directory outside the project directory, right-click the file and selectRefactor > Move from the Eclipse menu. Browse to the new location and click OK. You can also drag a file to a new location. Either way, Teamprise pends a rename to the file and a check mark appears over the label in your Eclipse resource view.

To change the name of a resource, right-click the file and select Refactor > Rename from the Eclipse menu. Type the new name and click OK. Teamprise pends a rename to the file and a check mark appears over the label in your Eclipse resource view.



Click the check-in icon to commit pending changes to the server.

myeclipse中的webroot目录

你看一下webapps你的projectname下有WebRoot吗?WebRoot仅仅是开发态的东西 运行态不会有一个东西。

WebRoot下的东西会Copy到webapps下的projectname下,所以不会有WebRoot这个目录,LZ在URL里面不应该有WebRoot了
jansel (资深程序员) 2009-09-04
web project 被部署到tamcat目录下的webapps目录下!

部署完后,在webapps目录下将自动新建一个名为你的project的名字。

Eclipse 开发WEB项目所遇问题 WebContent WebRoot



最近在做Web 项目时,新建了一个WEB 项目,如webdemo,eclipse默认的build路径为build, WEB-INF存放于WebContent下面,今改了一个build路径和WebContent名字,发现项目不可用了,

1. 具体修改过程过,把WebContent 改为 WebRoot
2. 把build路径从build/classes 改为 webdemo/WebRoot/WEB-INF/classes

在修改之前原存放于lib下的jar包都存于eclipse项目的Libraries/Web App Libraries目录下面,改后,Web App Libraries 变为空了,而且Tomcat6.x在启动的时候也识别不了了。研究了一下午,终于找出问题所在,今天特发出来,以供后来的朋友参照。

我们打开所建项目目录,在根目录下面有一.settings\org.eclipse.wst.common.component文件,
在刚新建一个项目时,此文件下面的内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="webdemo">
<wb-resource deploy-path="/" source-path="/WebContent"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="context-root" value="webdemo"/>
<property name="java-output-path" value="/webdemo/build/classes"/>
</wb-module>
</project-modules>

改后;发现少了一句<wb-resource deploy-path="/" source-path="/WebContent"/>,所以我们要手动把它加下,最后改正后的内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="webdemo">
<wb-resource deploy-path="/" source-path="/WebRoot"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="context-root" value="webdemo"/>
<property name="java-output-path" value="/webdemo/build/classes"/>
</wb-module>
</project-modules>

这样我们的eclipse web 项目又可以像以前一样运行,而且所有lib包下的jar也会自动存入Libraries/Web App Libraries目录下面。

2012年1月26日星期四

Importing a JAR file with eclipse - Dev Shed

Importing a JAR file with eclipse - Dev Shed

In project explorer right click on the folder/package where you want to import the JAR. Then choose "Import". In the import wizard, select General > File system. Browse for the JAR and select it.

Now you imported the JAR, but before you can use it, you need to add it to the classpath. Once again in project explorer right click on the project root folder, select Properties. In the properties menu select Java Build Path. In Java Build Path open the libraries tab and click on "Add JARs..." and browse for the JAR you just imported.

If you do not wish to actually import the package to your project but just use it, then you can skip the first part of this instruction and directly go to the "Libraries" tab in the Java Build Path. This time you should click on "Add external JARs..." and browse for the JAR in your file system.

Servlet and JSP development with Eclipse WTP 2

Servlet and JSP development with Eclipse WTP

6.4. Adjust web.xml

Set the JSP page as the welcome page for your application. This is optional but make it easier because the JSP is automatically opened if the application is started. Modify the file "WebContent/WEB-INF/web.xml" to the following.

     

2012年1月25日星期三

如何将tomcat添加为linux系统服务 - 已回答 - 搜搜问问

如何将tomcat添加为linux系统服务 - 已回答 - 搜搜问问

1. 首先需要将$Tomcat_HOME/bin目录下的Catalina.sh脚本复制到目录/etc/init.d中,重命名为tomcat,文件名即为以后的服务名
2. 修改刚才复制的tomcat脚本:
  a. 在脚本的第三行后面插入下面两行

  # chkconfig: 2345 10 90
  # description:Tomcat service

  第一行是服务的配置:第一个数字是服务的运行级,2345表明这个服务的运行级是2、3、4和5级(Linux的运行级为0到6);第二个数字是启动优先级,数值从0到99;第三个数是停止优先级,数值也是从0到99。
  第二行是对服务的描述

b. 在脚本中设置 CATALINA_HOME 和 JAVA_HOME 这两个脚本必需的环境变量,如:

    CATALINA_HOME=/usr/share/tomcat
    JAVA_HOME=/usr/share/java/jdk

经过实验发现,即使在系统中设置了这两个环境变量也没有用,只好在这里再设置一遍

3. OK!现在就可以用service tomcat start|stop|run来管理tomcat服务了
4. 为了能让服务自动运行,还得将服务添加到系统中去
  终端运行下列命令,将tomcat服务添加到系统服务中:
    chkconfig --add tomcat
  现在使用setup命令查看系统服务,就可以看到tomcat服务乖乖地在列表中了吧,你可以在这里设置让小猫随着系统一块启动啦。