简体   繁体   English

如何在Eclipse中构建Java Servlet?

[英]How to build a Java Servlet in Eclipse?

I'm new to Java. 我是Java新手。 I have to modify this Web Servlet that is running on my Tomcat. 我必须修改在Tomcat上运行的Web Servlet。 The Webapps folder contains several files and directories, but only one .JAR file. Webapps文件夹包含多个文件和目录,但只有一个.JAR文件。 I managed to decompile it using Java Decompiler JD-GUI, but when I create the project in Eclipse from the decompiled source and try to Validate it, Eclipse shows me around 389 errors. 我设法使用Java Decompiler JD-GUI对其进行了反编译,但是当我从反编译源在Eclipse中创建项目并尝试对其进行验证时,Eclipse向我显示了389个错误。 Errors like 像这样的错误

HttpServlet cannot be resolved to a type HttpServlet无法解析为类型

And I don't even know which Eclipse button rebuilds the .JAR file. 而且我什至不知道哪个Eclipse按钮可以重建.JAR文件。 Can anyone help me? 谁能帮我?

Your eclipse project will need to include the libraries that the servlet relies on to work. 您的eclipse项目将需要包括servlet依赖于工作的库。

If you create the Eclipse project as a Dynamic Web Project it will set up some of the basic structure needed, including the relevant libraries. 如果将Eclipse项目创建为Dynamic Web Project,它将建立一些所需的基本结构,包括相关的库。 You may need to include other libraries if the original code relies on them, but from your description it seems fairly unlikely. 如果原始代码依赖于其他库,则可能需要包括它们,但是从您的描述来看,这似乎不太可能。

You can create a JAR file from the Eclipse File Menu. 您可以从Eclipse File Menu创建一个JAR文件。 click Export..., and select Java->Jar file. 单击导出...,然后选择Java-> Jar文件。

Many projects will use ANT which allows you to define scripts to perform tasks needed to compile, package, deploy and test a project. 许多项目将使用ANT,它允许您定义脚本来执行编译,打包,部署和测试项目所需的任务。

you create the Eclipse project as a Dynamic Web Project it will set up some of the basic structure needed, including the relevant libraries. 您将Eclipse项目创建为Dynamic Web Project,它将建立所需的一些基本结构,包括相关的库。 You may need to include other libraries if the original code relies on them, 如果原始代码依赖于其他库,则可能需要包含它们,

create a JAR file from the Eclipse File Menu 从Eclipse File菜单创建JAR文件

click Export..., and select Java->Jar file. 单击导出...,然后选择Java-> Jar文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM