A few crudely put points might help you understand :) - getSystemResource is a static method, so you're calling the same thing regardless of what instance of ClassLoader you call it on. Convention says you shouldn't call static methods on an instance and some IDEs, e.g. Eclipse will probably warn you of this. Consider what would happen if you called a static method on an instance variable that is null.
- OSGi bundles have their own classloader. The framework wires bundles together such that the classloader of a bundle will only be able to see classes from packages it imports (this is the mechanism that allows different versions of the same package to exist in a runtime environment) - using getSystemResource uses the system (top level) classloader try and load a resource, which will won't work because system classloader is unaware of the OSGi bundle class loaders - getResource is an instance method on ClassLoader, so it uses the actual class loader you are referencing. Thus, foreign.class.getClassLoader() is the class loader of the bundle that the foreign class lives in. Hope that helps. Cheers, Chris 2010/4/15 <[email protected]> > On Thursday 15 April 2010 12:28:25 Karl Pauls wrote: > > foreign.class.getClassLoader().getResource(name) > > works perfectly, thanks! can you please explain the difference? I find > it > not clear from the documentation. > > -- > Lic. Marcos Dione > Engineer Expert - Hop Project > http://hop.inria.fr/ > INRIA Sophia Antipolis - Méditerranée > Phone: +33 (0)4 92 38 79 67 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >

