• 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

ClassLoader

 
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's the difference between ClassLoader.getSystemResourceAsStream and ClassLoader.getResourceAsStream ??
 
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
getSystemResource() will only consult the "system ClassLoader", while getResource() will consult the ClassLoader the method is called on. The system ClassLoader is the "built-in" one, the one that loads classes from the CLASSPATH when an application starts up.
No Java programmer should miss reading Ted Neward's two excellent articles on ClassLoaders here and here.
 
Ronnie Phelps
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So then all of my classes that I created in a single application should have the same classloader?
 
Ernest Friedman-Hill
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
"Should" meaning "will, generally" or "should" meaning "it is good practice to?" The former, yes. The latter, not especially. If you need multiple ClassLoaders, then they're a good thing. If you don't, then you don't, and that's fine too.
Anyway, the answer to your question is that they will, in general, if you don't do anything special -- i.e., if you don't create your own class loader.
 
reply
    Bookmark Topic Watch Topic
  • New Topic