Getting java.awt.HeadlessException when running the JasperViewer.viewReport (JasperPrint) method

I get an 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 do not find a solution to this error.

+4
source share
1 answer

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

Throw when a code 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 and Font objects available for a Java (tm) platform-specific application.

( Source )

Make sure your source report file ( etiquetaEndereco.jrxml ) calls fonts that cannot be installed on your system.

+2
source

Source: https://habr.com/ru/post/1444919/


All Articles