gpt4 book ai didi

java - 在运行 JasperViewer.viewReport(JasperPrint) 方法时获取 java.awt.HeadlessException

转载 作者:搜寻专家 更新时间:2023-11-01 03:26:12 24 4
gpt4 key购买 nike

我在 Ubuntu 11 上运行此代码时遇到错误:

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

堆栈:

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)

我找不到解决此错误的方法。

最佳答案

如 Java 文档所示,java.awt.HeadlessException 是:

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 )

并且,对于 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 )

检查您的报告源文件 (etiquetaEndereco.jrxml) 是否正在调用您的系统上无法安装的字体。

关于java - 在运行 JasperViewer.viewReport(JasperPrint) 方法时获取 java.awt.HeadlessException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13297028/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com