File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

WAR file and its inside classes

 
Frank Sikuluzu
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my "app.war", it includes WEB-INF/classes/Servlet.class, Standalone.class, Action.class, etc.

The Standalone.class is a simple java application that uses some other Action.class included in the WEB-INF/classes/ dir.

Now, if I give somebody this "app.war" and they just want to run "Standalone.class", here are the questions ---

1. if they simply add "app.war" into their classpath, can you run "Standalone.class" at any directory ?

2. if they only deploy "app.war" to their application server WITHOUT adding it to the classpath, can they run he "Standalone.class" ?

thanks.
 
Rovas Kram
Ranch Hand
Posts: 135
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Adding to the classpath is not going to work because the path part of the is incorrect. I'm sure your package name doesn't start with WIN-INF for example.
2) Adding the classes to WEB-INF/classes will make them available to any classes that are loaded at the web-app level: servlets, jsp, classes in WEB-INF/lib. At least that's the way it works in Weblogic.
 
Frank Sikuluzu
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rovus. I understand your answer to the first question. But for the second question, what I want to know was --

I only add "app.war" into the application server's deployment directory. And the server does NOT expand this WAR file into a hierachy directory structure, i.e. you will not see those .class files in WEB-INF/classes. If this is the case, then can the user run "Standalone.class" either within or outside the web application directory ?
 
Rovas Kram
Ranch Hand
Posts: 135
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it matters whether or not it's expanded. The classes that are in the WEB-INF/classes or WEB-INF/lib directories will only be available among themselves(e.g. to classes in WEB-INF...). For example a classpath that was loaded from the system classpath will not have access to any of the classes in WEB-INF.
 
Peter Bell
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about you put your classes in a jar file. Then add the jar file to /WEB-INF/lib/ in the war file. Then distribute the jar file when people would need to run things standalone?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic