Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
757 views
in Technique[技术] by (71.8m points)

jasper reports - Getting java.awt.HeadlessException on running JasperViewer.viewReport(JasperPrint) method

I'm getting the error with this code running on Ubuntu 11:

JasperReport jasperReport = JasperCompileManager.compileReport("/resources/etiquetas/etiquetaEndereco.jrxml");
JasperPrint print = JasperFillManager.fillReport(jasperReport, parametros);
JasperViewer.viewReport(print);

Stack:

GRAVE: java.awt.HeadlessException
    at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)
    at java.awt.Window.<init>(Window.java:432)
    at java.awt.Frame.<init>(Frame.java:403)
    at java.awt.Frame.<init>(Frame.java:368)
    at javax.swing.JFrame.<init>(JFrame.java:158)
    at net.sf.jasperreports.view.JasperViewer.<init>(JasperViewer.java:264)

I don't find solution for this error.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As Java documentation shows, java.awt.HeadlessException is:

Thrown when code that is dependent on a keyboard, display, or mouse is called in an environment that does not support a keyboard, display, or mouse.

(Source)

and, for java.awt.GraphicsEnvironment:

The GraphicsEnvironment class describes the collection of GraphicsDevice objects and Font objects available to a Java(tm) application on a particular platform.

(Source)

Check if your report source file (etiquetaEndereco.jrxml) is calling fonts that could not be installed on your system.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...