• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

ClassLoader  RSS feed

 
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the difference between ClassLoader.getSystemResourceAsStream and ClassLoader.getResourceAsStream ??
 
author and iconoclast
Sheriff
Posts: 24220
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 24220
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!