how to call a class in war file from another class outside the war file. Iam getting problem when accessing that class from war file how to overcome that problem.
2 Answers
You don't... Unless the War refers to a jar that is in both wars...
A war is a collection of jars, as a sort of wrapper...
So make more jars, and import those in different wars
Try to only create classes in a War that are needed for that webservice only... Not helper classes, since they might be necessary for other applications/services
Jar: collection of Java Classes, property files, so that a collection of classes can be ran from within a computer (Wiki on jar https://en.wikipedia.org/wiki/JAR_(file_format))
java -jar xxx.jar
War: Web ARchive (Wiki on war https://en.wikipedia.org/wiki/WAR_(file_format))
is meant to be put inside a webserver (like Tomcat/Jetty) with has a collection of Jars, and configuration information necessary for link with internet... Like REST, JSP, Html...
Ear: Enterprise ARchive (wiki on ear https://en.wikipedia.org/wiki/EAR_(file_format))
Has a collection of War and Jar, run in Application servers like JBoss and GlassFish
Additional War vs ear see .war vs .ear file
-
1For additional info on what a collection of jars is, [see this](http://www2.wcoil.com/~aux/MB/MBEARLYJARS.JPG) – musefan Jul 02 '15 at 12:48
-
-
@musefan that's only half the answer... Then what's the war? The closet itself? – Danielson Jul 02 '15 at 12:49
-
The war is not only a collection of jars, but an archive with special content (`WEB-INF/web.xml`, etc.) – Konstantin Yovkov Jul 02 '15 at 12:49
-
Right right... My answer is a bit simplistic... I'll fix that... But for the purpose of understanding/knowing wars cannot be imported into war... Except maybe in Ears? – Danielson Jul 02 '15 at 12:50
-
1@Danielson: I don't know much about closets, but I think [this completes the answer](http://madbean.com/anim/jarwars/) – musefan Jul 02 '15 at 12:53
WARs are specifically intended to live in isolation from the other jars/ejbs in the package, they have their own classloader and the wars do not by default reside in the path in any other war, jar, or ejb.
If there is a common functionality this should be moved into a jar that is shared between the artifacts.

- 266
- 1
- 13