0

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.

chandu
  • 1
  • 1
  • 1
    You need to provide context, and examples, and be more specific about exactly what it is you are trying to achieve – musefan Jul 02 '15 at 12:45

2 Answers2

0

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

Community
  • 1
  • 1
Danielson
  • 2,605
  • 2
  • 28
  • 51
0

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.

Stig Tore
  • 266
  • 1
  • 13