简体   繁体   中英

How to build a Java Servlet in Eclipse?

I'm new to Java. I have to modify this Web Servlet that is running on my Tomcat. The Webapps folder contains several files and directories, but only one .JAR file. 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. Errors like

HttpServlet cannot be resolved to a type

And I don't even know which Eclipse button rebuilds the .JAR file. Can anyone help me?

Your eclipse project will need to include the libraries that the servlet relies on to work.

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. 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. click Export..., and select Java->Jar file.

Many projects will use ANT which allows you to define scripts to perform tasks needed to compile, package, deploy and test a project.

you create the Eclipse project as a Dynamic Web Project it will set up some of the basic structure needed, including the relevant libraries. You may need to include other libraries if the original code relies on them,

create a JAR file from the Eclipse File Menu

click Export..., and select Java->Jar file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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