Re: jar files and resources !!



Hi,

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.
or
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
"images/image.gif"

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

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

Regards,

Arnaud





<esamsalah@xxxxxxxxx> a écrit dans le message news:
1113826580.463711.244740@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> 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
>


.