Mark Fenbers | 14 Jun 01:56
Picon
Favicon

Resource from a jar file

I'm having some trouble with mergeTemplate() in that it seems to be 
unable to open a template file if it is packaged in a jar file.  In my 
Java code, I use getResource("resources/velocity.template").getFile() 
[from the "Class" object] to expand the relative location to a full 
URL.  This is for flexibility/portability...  This approach works fine 
when *not* running my app from a Jar file because the file name expands 
to a simple path, something like: 
"/home/mark/resources/velocity.template" whereas when run from a Jar 
file, it expands to something like: 
"file:/home/mark/MyApp.jar!/resources/velocity.template", and thus 
mergeTemplate doesn't like this format... probably the "file:" or the 
"!" throw it off.

I'm not sure how to get past this hurdle.  Any ideas?

Mark

Gmane