velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Fenbers <>
Subject mergeTemplate - non-standard resource
Date Tue, 05 May 2009 12:01:27 GMT
I need to give some background info before I ask the Velocity question...

I've changed my code to use class resources instead of absolute or 
relative pathnames.  In other words, I changed this:

Image myImage = new Image(display, 

to this:

Image myImage = new Image(display, 

This is less direct, but has several advantages, including that 
getResource uses the class location (bin/gov/noaa/ohrfc) to complete the 
full pathname of "resource/rvf.icon.png". The getFile() method will 
return the full pathname of the file (which is: 
This makes it more portable, and makes it more compatible with using 
Java Web Start for this application.  Using getResource(), my code 
doesn't break if I move my classes somewhere else besides 

The problem comes in with Velocity's mergeTemplate() method which chokes 
when an absolute pathname is used.  It also chokes when I use a pathname 
that is relative to the class location.  Rather, it requires something 
in between whereby I have to specify the class location *and* the 
relative path to the template file, namely, I need to specify 
"bin/gov/noaa/ohrfc/resources/SHEF.template", whereas I want to specify 
"resources/SHEF.template" or give it the full absolute pathname.

I am using version 1.6.1-dep.  Does a later version fix this problem?  
Or is there another work-around where I can either: 1) avoid giving the 
class location (bin/gov/noaa/ohrfc)' or 2) give the entire absolute path 
location [which can be determined on-the-fly using getResource().getFile()]?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message