Re: jar files and resources !!


I can't say anything regarding performance .

However, here is what you want for getting resources from jar :

getClass().getClassLoader().getResourceAsStream(String name)
which gives you an InputStream from the resource.
getClass().getClassLoader().getResource(String name)
which gives you the URL of the resource.

if your jar contains image.gif inside a /images directory, name would be

Note that getClass() can be called on an instance, you may also call the
class statically e.g :

MyApp.class.getClassLoader().getResourceAsStream(String name)



<esamsalah@xxxxxxxxx> a écrit dans le message news:
> Dear All
> what is best :
> to include resources (images,text files,etc) in the JAR
> or to leave then as external
> for both is there a difference between loading a resource from the JAR
> and from the FileSystem
> I need an example please.
> Thanks