DISPLAY variable needed for Filling a report?

Hello out there,

I generated a nice report with iReport and now
I want to use a litte java program to generate reports in "batch" on a linux server. I
coded this little piece of snippet:

import net.sf.jasperreports.engine.*;
import java.util.HashMap;
public class runReport
{
public static void main(String[] args)
{
JasperReport jasperReport;
JasperPrint jasperPrint;
try
{
jasperReport = JasperCompileManager.compileReport(
"../hrmodul/Jobs.jrxml");
jasperPrint = JasperFillManager.fillReport(
jasperReport, new HashMap(), new JREmptyDataSource());
JasperExportManager.exportReportToPdfFile(
jasperPrint, "../hrmodul/simple_report.pdf");
}
catch (JRException e)
{
e.printStackTrace();
}
}
}

And there is the problem, it throws me an exception in line with the FillManager:
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:175)
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java:180)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:91)
at net.sf.jasperreports.engine.util.JRGraphEnvInitializer.initializeGraphEnv(JRGraphEnvInitializer.java:58)

and so on...

What is this? I don't want to SHOW the report.

Many thanks.
Frank
Hauptlorenz's picture
Joined: Aug 27 2006 - 3:30pm
Last seen: 16 years 9 months ago

3 Answers:

Hi,

Even if you are not showing the report, JR would still use AWT to do the layout and calculations and needs fonts metrics and staff.
So you either install and X-server or use JDK with the -Djava.awt.headless=true option (requires JDK > 1.4) or use other solutions such as Xvfb or PJA.

I hope this helps.
Teodor
teodord's picture
47111
Joined: Jun 30 2006 - 9:00am
Last seen: 2 days 3 hours ago
Hi Teodor,

yes, this -D option does work. Has this any other "bad" effects?

Thank you very much,
Frank
Hauptlorenz's picture
Joined: Aug 27 2006 - 3:30pm
Last seen: 16 years 9 months ago
The -djava.awt.headless=true option still uses the X11 libraries, it just doesn't require a running X server. The end results are the same

No bad effects that I have encountered. I imagine it uses a bit more memory, since the font metrics, etc are loaded into it via the Xlib instead of being retained on the X server. Just a guess though.

-Barry
bklawans's picture
4010
Joined: Jul 6 2006 - 1:21pm
Last seen: 6 years 2 months ago
Feedback
randomness