| Author |
ClassLoader
|
Ronnie Phelps
Ranch Hand
Joined: Mar 12, 2001
Posts: 329
|
|
|
What's the difference between ClassLoader.getSystemResourceAsStream and ClassLoader.getResourceAsStream ??
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24054
|
|
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.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Ronnie Phelps
Ranch Hand
Joined: Mar 12, 2001
Posts: 329
|
|
|
So then all of my classes that I created in a single application should have the same classloader?
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24054
|
|
"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.
|
 |
 |
|
|
subject: ClassLoader
|
|
|