简体   繁体   中英

How to call a class in war file from another class outside the war file?

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM