• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jar vs directory class

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mean WEB-INF/classes/com/sample/A.class? The Servlet spec says that the "classes" directory will be searched before the "lib" directory.
 
nikki lorenzo
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
reply
    Bookmark Topic Watch Topic
  • New Topic