Understanding an imported WAR in Eclipse and its folder structure

I just imported a WAR file from an external site, which is basically a servlet in the Eclipse IDE (the project runs on Apache-Tomcat).

When I import it, it has a folder named Web Application Libraries . So here are a few of my newbies:

  • I'm not sure what exactly is the purpose of this folder? What does it do, why did you decide to use it in your project?

  • I see it has a folder named Improted Classes and foobar.class inside - why? (They seemed to be mirrored in the Web Content folder , although you can change the code here since they are foobar.java.)

  • There are also links to the foobar.jar files - they are also reflected in the WEB-INF / lib folder - why?

I know these are basic questions, but I'm just getting my head around Java and a web developer, so I'm sorry if they sound a little silly! - By the way, if anyone knows of any good online resource to learn more about project structures like this then let me know. I just need to get this stuff done as soon as possible - since the deadline for the project is pretty soon.

Greetings.

Here's a screenshot to help you visualize:

alt text

+1


source to share


4 answers


I am assuming this is a screenshot from the Project Explorer view. It doesn't display the exact folder and file structures, it adds a few sweets built from the project metadata.



  • To see the real structure of your project, try switching to the Navigator view.
  • When importing a WAR file, Eclipse does basically two things:
    • Creates a new web project and copies the WAR content to the "WebContent" subfolder of the new project.
    • Based on the WAR, it generates the project metadata (.project and .classpath files).
  • The Web Application Libraries section displays a list of the jar files that the WAR contained (in WEB-INF / lib
  • The "imported classes" (which I also see for the first time) seems to contain the classes found in the imported WARs (WEB-INF / classes) for which Eclipse was unable to find the corresponding source files. To fix this, create a new Java source folder in the project and move the classes you now have in the "firstResource" folder.
+2


source


The web application libraries are not a real directory, but rather a list of what Eclipse thinks are project libraries.

Typically this consists of all the jar files in WebContent / WEB-INF / lib /



Sometimes Eclipse no longer lists them in their real directory in the Eclipse Package Explorer ... but they still exist if you are looking with a different program.

+2


source


In Eclipse, if you are using Java Web Development View, you must configure:

  • Tomcat Server Runtime Providing Servlet Libraries
  • Java runtime
  • Other required libraries

Web application libraries that duplicate the first parameter in the project, so you don't need a local Tomcat installed in the development window.

The rest sounds dirty to me.

You have src / JavaSource folder with raw Java files. They don't have to be in web content - for your HTML, images, JSP, etc.

So, a typical project setup:

Project Name/
   JavaSource/ or src/ // holds all the Java Source Files, Servlets, Struts Actions
   WebContent/         // Nice root folder to hold web content files
       content files and folders
       WEB-INF/        // Web App Config folder
           lib/        // Libraries (but not tomcat ones)
           web.xml
           classes/    // Where your compiled Java goes, and configs (log4j.properties)

      

Some people put the JSP inside WEB-INF since it shouldn't be available in the JSP file state, only in the compiled state, which Tomcat makes itself.

+1


source


Simple, eclipse provides a multiple view of your project structure. The view you are viewing is definitely the Package Explorer view. In this view, anything that has a special icon in front is a helper that will help you make it easier to access certain stuff like external libraries (which are provided by software on your computer, or by eclipse itself or another project).

In eclipse go to menu-> window-> show view-> navigator In the Navigator view you will see the real folder structure of your project.

0


source







All Articles