java - JAR, when runs, looks for resource files inside the JAR (itselfe) or outside? -


a java program uses different files, stored under path "src/main/resources/files/files.drl". if export program run-able jar , run jar, these files inside jar or outside in folder src->main->resources->files ?

a sample code how these files used java program :

drlfilename = "./src/main/resources/files/files.drl"; fileinputstream fis = null; fis = new fileinputstream(drlfilename); kbuilder.add( resourcefactory.newinputstreamresource(fis), resourcetype.drl);    

how package application doesn't determine find resources in cases. in whatever directory tell in. if specify jar file, using various jar file apis (e.g. java.util.jar.jarfile), that's program find data. if in os's file system (e.g. using things java.io.fileinputstream) that's find data.

the exception when use classloader::getresource search classpath find specified resource. so, example, if classpath points single jar file, resource looked in jar file. note if use custom classloader implementation other places can searched -- urls, non-classpath paths/jarfiles, etc. possible source of bytes used custom classloader find resources -- depend on classloader designed do.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -