java - 从 Java 调用 JasperReports
问题描述
我正在尝试打印在 Netbeans 8.2 下使用 Jasper Reports 创建的报告,第一个报告它工作了几天,然后它停止工作,我收到一条错误消息
“线程“AWT-EventQueue-0”中的异常 java.lang.NoClassDefFoundError:org/apache/commons/digester/Digester”。
所有 Jasperreports Jar 文件都存在于我的项目目录“库”下。这是我用来从我的应用程序调用 Jasper 报告的代码。
try {
DBModule.ConnectDataBase.ConnectDataBase_Method();
conn = DBModule.ConnectDataBase.ConnectDataBase_Method();
//Get a stream to read the file
InputStream is = this.getClass().getClassLoader().getResourceAsStream(reportName);
JasperPrint jp = JasperFillManager.fillReport(is, null, conn);
JRViewer jv = new JRViewer(jp);
JFrame jf = new JFrame();
jf.getContentPane().add(jv);
jf.validate();
jf.setVisible(true);
jf.setSize(new Dimension(800,600));
jf.setLocation(300,100);
jf.setDefaultCloseOperation(2);
} catch (JRException ex) {
CustomControls.CustomTools.CustomMsgBox(ex.getMessage());
}
任何建议...
解决方案
您不仅需要“所有 Jasperreports Jar 文件”,还需要一些第三方库。请查看关于库要求的community.jaspersoft.com/wiki/jasperreports-library-requirements 。除非您没有使用 maven 或类似的东西,否则我想您需要将它们复制到您的类路径中。
推荐阅读
- java - 自定义注释以包装注释
- actions-on-google - 通过快速自托管迁移到 v2 API
- python-3.x - Python sqlite3,在 .format 的帮助下从列表中创建表列
- php - 找到数组元素后取出每个元素
- azure-devops - Azure DevOps 条件编译
- matlab - 在 MATLAB 中查找单个点的最近邻
- javascript - 如何将 Target 属性添加到新的 MouseEvent?
- javascript - 模板按钮不适用于 Javascript
- node.js - 如何使用 Node 和 Express 正确地提供动态图像?
- javascript - WebRTC 中的 ICE 连接失败