我为我的项目创建了一个可运行的jar,当我尝试打印报告时,我得到了异常,但是从netbeans开始它正在执行
Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:121)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:77)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:87)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:57)
at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:142)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:52)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
at UI.NewFrame.jMenuItem3ActionPerformed(NewFrame.java:1269)
at UI.NewFrame.access$3300(NewFrame.java:37)
at UI.NewFrame$32.actionPerformed(NewFrame.java:920)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
这是我用于项目的库
这是我的按钮打印
File namaFile = new File("src/Laporan/report.jasper");
try {
JasperReport jasper = (JasperReport) JRLoader.loadObject(namaFile.getPath());
JasperPrint jp = JasperFillManager.fillReport(jasper, null, kon.getkoneksi());
JasperViewer.viewReport(jp,false);
} catch (Exception ex) {
javax.swing.JOptionPane.showMessageDialog(rootPane, ex.getMessage());
}
后来我发现我必须手动添加字体,但它仍然不适用于我。