Jump to content
We've recently updated our Privacy Statement, available here ×

Adding images to a report with no XML Design


russ_87

Recommended Posts

Hi All,

I'm fairly new to Jasper Reports, and have been trying to create my reports using only Java code, basing it off of the noXMLDesign App that comes with the samples. One thing that isn't included, is how to add images to the report. I've added the following (see code), but when the report tries to compile, I get the following error:

"illegal start of expression
                value = (java.lang.String)(![CDATA["D:My DocumentsNetBeansProjectsSTAT 0.1buildImageslogo.jpg"]]); //$JR_EXPR_ID=12$"

Now, my question is, how do I properly set the expression for the image in Java? The expression that I wrote is what the iReport builder gave me when I added an image to the report, I just added the escape characters for quotations.

Appreciate any help.

Regards,

Russell
 

Code:


Post Edited by russ_87 at 03/08/2010 21:40
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I just noticed that this isn't even a fair representation of my problem. In the above, you can see I left out the escape character for the slashes in the file path, and the error backs that up. Let me try again.

This is what the iReport designer gives me for the expression:

<imageExpression class="java.lang.String"><![CDATA["D:\\My Documents\\NetBeansProjects\\STAT 0.1\\build\\Images\\logo.jpg"]]></imageExpression>

My code:

expression.setText("![CDATA[\"D:\\\\My Documents\\\\NetBeansProjects\\\\STAT 0.1\\\\build\\\\Images\\\\logo.jpg\"]]");

The error:

D:\My Documents\NetBeansProjects\STAT 0.1\StudentReport_1268185816578_660519.java:201: illegal start of expression
                value = (java.lang.String)(![CDATA["D:\\My Documents\\NetBeansProjects\\STAT 0.1\\build\\Images\\logo.jpg"]]); //$JR_EXPR_ID=12$
 

There is also an arrow that points to the opening square bracket after the exclamation point.

Thanks again for any help. Really I just need to know how I can properly set the image expression in Java.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...