I do it this way – image is passed by path:
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("logo", ClassLoader.getSystemResource("logo.jpg").getPath());
.jrxml
<parameter name="logo" class="java.lang.String"/>
...
<image>
<reportElement x="0" y="1" width="100" height="37"/>
<imageExpression><![CDATA[$P{logo}]]></imageExpression>
</image>
…or image is passed as InputStream
(I don’t know why, but <image>
need to have onErrorType
attribute set to "Blank"
, otherwise it does not work – throws exception):
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("logo", ClassLoader.getSystemResourceAsStream("logo.jpg"));
.jrxml
<parameter name="logo" class="java.io.InputStream"/>
...
<image onErrorType="Blank">
<reportElement x="0" y="1" width="100" height="37"/>
<imageExpression><![CDATA[$P{logo}]]></imageExpression>
</image>