What is the difference between a WAR and a EAR application? I got this .war vs .ear file but yet no hint. Are there any practical examples which can explain when to use which? Yes I mean if I have an application (say, online shopping cart), why would I package it as a EAR instead of packaging it as a WAR?
Asked
Active
Viewed 911 times
-2
-
-1 ,so the question u linked has exactly the same title with yours and the answer to the question has 106 upvotes,are you kidding me? – SteveL May 05 '14 at 07:12
-
@OlegEstekhin ,you dont say... he even linked the question – SteveL May 05 '14 at 07:13
-
could you clarify what you expect as an answer? – eis May 05 '14 at 07:14
1 Answers
3
Assuming you'd have an online shop, you'd package it in a WAR if it only contains static resources (html, css, javascript) and servlets/jsps/java classes, so standard java web components.
You'd package it into an EAR if you want to add Java EE capabilities such as EJBs (message-driven, session or container-managed beans), enterprise messaging or combine multiple .wars and .jars into one application archieve.
Typically the disctinction is that if you want EJBs, you go with EARs, otherwise go with WARs.

eis
- 51,991
- 13
- 150
- 199