The "normal" way to this is to use a parameter that contains the base path
<parameter name="IMAGE_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["/home/name/app/test/reportTemplates/images/"]]></defaultValueExpression>
</parameter>
Set the defaultValueExpression
so that you can use it in preview (iReport, JasperSoft studio) and isForPrompting="false"
to avoid that it is asked everytime you preview.
Then in the imageExpression
use the parameter as base path
<imageExpression><![CDATA[$P{IMAGE_DIR} + "company_logo.JPG"]]></imageExpression>
When is time to fill the report (application run-time) set the IMAGE_DIR
parameter to the correct deployed path passing it in the parameter map.
es. if you are using java GUI you like a relative path to where you are installed
File imageDir = new File("images");
String imageAbsolutePath = imageDir.getAbsolutePath() + File.separator;
es. if you have web application (jsp/jsf) you like to find the a WEB-INF path of your deployed application
ServletContext context = request.getServletContext();
String imageAbsolutePath = context.getRealPath("/WEB-INF/images") + "/";
Now that we have the absolute path of our image directory we add it to the parameter map that we pass to the fillManager.
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("IMAGE_DIR",imageAbsolutePath);
//..here goes all the other parameter you may set.
and then just pass the parameter map to the fillManager...
NOTE: this is an example I do not know how you fill
JasperPrint print = JasperFillManager.fillReport(report, paramMap, connection);