这是我的来源线打印我的发票页。我的报告不在java包中。我将它保存在一个名为"report“的文件夹中,该文件夹位于与我的java项目相同的分区中。现在我有NoClassDefFoundError了。
try {
String date1 = new SimpleDateFormat("yyyy-MM-dd").format(isdate.getDate());
String time1 = istime.getValue().toString().split(" ")[3];
date1 = date1 + " " + time1;
String date2 = new SimpleDateFormat("yyyy-MM-dd").format(redate.getDate());
String time2 = retime.getValue().toString().split(" ")[3];
date2 = date2 + " " + time2;
JRTableModelDataSource dataSource = new JRTableModelDataSource(jTable1.getModel());
String reportsource = " D://report/report1.jrxml";
Map<String, Object> params = new HashMap<String, Object>();
params.put("inid", txtInvoiceID.getText());
params.put("cuname", txtCuName.getText());
params.put("cuadd", txtCuid.getText());
params.put("cutp", txtTPNo.getText());
params.put("isdate", date1);
params.put("redate", date2);
params.put("advance", txtAdvance.getText());
params.put("due", txtDue.getText());
params.put("total", txtGtotal.getText());
JasperReport jasperReport = JasperCompileManager.compileReport(reportsource);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, dataSource);
JasperViewer.viewReport(jasperPrint, false);
JOptionPane.showMessageDialog(null, "Done");
} catch (Exception e) {
System.out.println(e);
}
发布于 2013-10-02 10:18:58
编译器在编译时找到必要的库,但是程序无法在运行时在类路径中找到它们。将Jasper库添加到您的类路径。(我有它的受抚养人。)它们中的大多数都是)
https://stackoverflow.com/questions/19143867
复制