> > Unless you have a priori knowledge that in every possible environment > you'll actually have a File, the best thing is to open a stream from > that URL directly. > </PetPeeve> >
I actually do this already (getResourceAsStream()), but good to point that out (in case someone else might read that). This is one of the things I have learned when it comes to resource loading: never assume anything. > I don't see why you should need to use the context classloader if the > resources are within the same domain (realm? scope? I'm looking for a > word which is a more formalized form of 'in the same JAR') as the class > you were referencing with > this.getClass().getClassLoader().getResource(). I'm assuming the > resources in question are definitely being included in the produced JARs? Yes, the resources will be included in the JAR. I don't know if it's actually necessary to go via the context classloader, but it seems to work well so far. My original approach has usually worked too, but not in this case. But this might be also caused by the way how I am currently starting the application. As I already said: I don't know why this has to be so complicated. The whole JAR/resource concept is quite nice, but its implementation... everytime I think I have understood how everything works, I find something which does not work as expected. If someone can point me towards some good books, articles, documentation on this subject, I would be really thankful. Simon
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
