Jump to content
Changes to the Jaspersoft community edition download ×

DISPLAY variable needed for Filling a report?


Hauptlorenz

Recommended Posts

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

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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

Link to comment
Share on other sites

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

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...