wood burning stoves*
The moose likes Beginning Java and the fly likes jar vs directory class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "jar vs directory class" Watch "jar vs directory class" New topic
Author

jar vs directory class

nikki lorenzo
Greenhorn

Joined: Jan 12, 2004
Posts: 28
Question: If i have a class, com.sample.A.class located in WEB-INF/lib/B.jar and a similar class in com/sample/ which gets picked up by the class loader?

Will appreciate ur help on this. Thanks.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

You mean WEB-INF/classes/com/sample/A.class? The Servlet spec says that the "classes" directory will be searched before the "lib" directory.


[Jess in Action][AskingGoodQuestions]
nikki lorenzo
Greenhorn

Joined: Jan 12, 2004
Posts: 28
Right. Thanks Ernest. Almost forgot that one.

In relation to that, suppose i have 2 jars in WEB-INF/lib. A.jar containing MyClass.class and B.jar containing containing A.jar/MyClass.class. Which version gets loaded this time?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

I haven't looked for you, but if there's an answer to your question, you'd most likely find it in the servlet specification just like the answer to your previous question.

I doubt that the order in which JAR files in the WEB-INF/lib directory are included, is well-defined. Is this an exam question or are you actually writing a web application in which this is important? It's not a good idea to make your webapp dependent on this...


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jar vs directory class