Add new comment

Resources in embedded jar file not found

I have restructured my project to seperate functions into different jar files (I'm using Maven Master project)

However now, when I build with Jar2Exe my sub-jar file now can't locate resources within the jar (I'm using Google Flyway to perform database migration on SQL files in resource folder)

My code within the jar file

URL resource = Thread.currentThread().getContextClassLoader().getResource(dataload[0]);
if (resource != null)  {
    File resFile = URLHelper.asFile(resource);
    System.out.println("RESOURCE FILE ["+dataload[0]+"] found["+resFile.exists()+"]");                   

}
else {
    System.out.println("RESOURCE URL returned ["+(resource != null ? resource.toString() : "is null")+"]");                   

}

Now returns

RESOURCE URL returned was [is null]

 

From what I have read elsewhere on this forum I am using the correct ClassLoader - Thread.currentThread().getContextClassLoader().

I am building this via J2EWIZ with the following

J2EWIZ MyApplication.jar ^

...

/embed lib\MyDBUtility.jar ^

...

/config "classpath lib\bcprov-jdk15on-1.51.jar" ^

 

And I have tried adding as "/config "classpath..." (as above for Bouncy Castle jars) but that gives a class not found - and anyway I'm not keen on have this jar external to the executable.

Hoping you can help.

Thanks

David