Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding imported WAR in Eclipse and its folder structure

Tags:

java

eclipse

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

When I import it it has a folder called Web App Libraries. So here are a few of my newbie questions:

  1. I am unsure about what the exact purpose is of this folder is? What does it do, why would you choose to have it in your project?

  2. I see that it has a folder called Improted Classes and foobar.class files inside it - why?
    (These seemed to be mirrored in Web Content folder - although here you can modify the code as they are foobar.java.)

  3. There are references to foobar.jar files too - these are also mirrored in WEB-INF/lib folder too - why?

I know these are basic type questions but I'm just getting to grips with Java and website dev, so apologies if they sound a bit dumb! - BTW if anyone knows any good online resource to understand more about project file structures like this, then let me know. I just need to get to grips with this stuff asap - as the project deadline is fairly soon.

Cheers.

Here's a screenshot just to help you visualise:

alt text

like image 785
Vidar Avatar asked Dec 12 '25 22:12

Vidar


2 Answers

I assume this is a screenshot from the 'Project Explorer' view. It does not display exact folders and files structure, is adds a few candy constructed from project's metadata.

  • To see real structure of your project, try switching to the 'Navigator' view.
  • During a WAR file import, Eclipse basically does two things:
    • Creates a new web project and copies WAR's content to 'WebContent' subfolder of the new project.
    • Based on the WAR, it constructs project's metadata (.project and .classpath files).
  • The 'Web App Libraries' section displays list of jar files that the WAR contained (in WEB-INF/lib
  • 'Imported classes' (which I also see for a first time) seem to contain classes found in the imported WAR (WEB-INF/classes), for which Eclipse was not able to find any corresponding source files. To fix this, create a new Java source folder in the project and move the classes you now have in 'firstResource' folder to it.
like image 101
david a. Avatar answered Dec 15 '25 20:12

david a.


Web App Libraries isn't a real directory, but rather a listing of what Eclipse thinks are this project's libraries.

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

Sometimes, Eclipse no longer lists them in their real directory in Eclipse's Package Explorer... but they're still there if you look with another program.

like image 23
Powerlord Avatar answered Dec 15 '25 20:12

Powerlord



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!