It's not a secret anymore!
The moose likes Java in General and the fly likes import statements saga Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "import statements saga" Watch "import statements saga" New topic

import statements saga

bob reilly
Ranch Hand

Joined: Jan 22, 2007
Posts: 44
I posted an issue a few days ago and received some very good responses - so thank you all.

My primary complaint was/is I had import statements referencing classes under WEB_INF without any source code.

The solution was to place .jar files containing the ready-compiled classes into my classpath. Subsequently - you can use normal import for the compiled classes. My question - when unzipping the application - would / should the jar files be reflected in the WEB-INF/lib path? Could they be placed elsewhere within the app?

Thank you for your comments...
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10819

I take it you are referring to deploying the war file.
When the war is exploded, the jar still remains under WEB-INF/lib which is automatically on the class path. The jars placed there will be picked up by default.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Shinelin Samuel
Ranch Hand

Joined: Mar 01, 2010
Posts: 55
'Unzipping the application' - Are you referring to unzipping WAR/EAR file. In that case, yes the jars will be placed inside the /WEB-INF directory of the extracted one.

The J2EE IDEs(eclipse, netbeans etc) however support, to have java libraries (.jars) to be linked with the code base by adding the .jar to the build path. But it is advisable to have it in WEB-INF if the jar is specific for your application, the reason being when you export the Source code to WAR, it will include only the jars inside your WEB-INF directory.
David Newton

Joined: Sep 29, 2008
Posts: 12617

bob reilly wrote:Could they be placed elsewhere within the app?

No. WEB-INF/lib is the location for application-specific libraries.
I agree. Here's the link:
subject: import statements saga
jQuery in Action, 3rd edition