13

Can you give me understanding of main difference between APP-INF and WEB-INF folders in javaEE applications.

Thanks

Sai Ye Yan Naing Aye
  • 6,622
  • 12
  • 47
  • 65
Ishikawa Yoshi
  • 1,779
  • 8
  • 22
  • 43

2 Answers2

23

APP-INF

In an enterprise application (EAR application) which contains many war and jars (eg.WebApp1.war, WebApp2.war, EJB1.jar and EJB2.jar.) and suppose all these Modules want to use some classes which is available as part of a Jar (common.jar). So in this case it is better to Place this jar file inside under “APP-INF” directory,that why we don't need to put the same Jar 4 times inside each and every Modules.

WEB-INF

WEB-INF is a directory that is a private area of the web application, any files under WEB-INF directory cannot be accessed directly from browser by specifying the URL.

See EAR application structure;

enter image description here

Sai Ye Yan Naing Aye
  • 6,622
  • 12
  • 47
  • 65
  • Thanks, and one more question, is there any difference between lib and classes in APP-INF and in WEB-INF? i mean it's only logical difference or no difference here? – Ishikawa Yoshi Aug 31 '12 at 08:00
  • @IshikawaYoshi WEB-INF represents one war, APP-INF represents more than one wars or jars. So lib and classes form both be different.APP-INF is aimed for common usages. – Sai Ye Yan Naing Aye Aug 31 '12 at 08:07
  • 1
    In another words application can see all jar if it placed in APP-INF and jars in WEB-INF can be see only in this WAR, i'm right? – Ishikawa Yoshi Aug 31 '12 at 08:11
  • 1
    Do note that this answer is correct only for WebLogic. APP-INF is a WebLogic proprietary feature. OP mentioned "JavaEE" applications. – Arjan Tijms Oct 01 '13 at 21:42
  • -1, as this is a WebLogic-specific feature, rather than JavaEE. – Isaac Nov 01 '13 at 01:10
21

Can you give me understanding of main difference between APP-INF and WEB-INF folders in java EE applications.

APP-INF is specific for WebLogic. In the Java EE standard it does not exist, hence for Java EE applications there is nothing to compare. Java EE does have an [EAR]/lib directory that takes the place of the non-standard APP-INF/lib. Optionally another directory can be configured in [EAR]/META-INF/application.xml"

<application>
   <library-directory>APP-INF/lib</library-directory>
</application>

There is no direct replacement for APP-INF/classes in standard Java EE. You'll have to jar these up as well and put them in [EAR]/lib as well.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140