问题
What have I done wrong here?
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
subreport_dir = "...\\Report\\subReport.jasper";
try {
compileView("...\\Report\\myReport.jrxml");
} catch (JRException ex) {
JOptionPane.showMessageDialog(this, "No Row");
System.out.println(ex.toString());
}
}
when I call the function
private static void compileView(String path) throws JRException {
Map<String, Object> param = new HashMap<String, Object>();
param.put("month", myMonth);
param.put("year", myYear);
param.put("SUBREPORT_DIR", subreport_dir);
param.putAll(param);
JasperReport jRp = JasperCompileManager.compileReport(path);
JasperPrint jPrint = JasperFillManager.fillReport(jRp, param, getConnection());
JasperViewer.viewReport(jPrint, false);
JasperViewer.setDefaultLookAndFeelDecorated(true);
}
I get this exception:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: net/sf/jasperreports/compilers/GroovyEvaluator
What should I do?
回答1:
Change the language tag in your report on the <jasperReport>
tag
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="subreport" language="groovy" pageWidth="555" pageHeight="842" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="6afeba62-b470-4dfb-a8fb-42e2226b906d">
language="groovy"
to
language="java"
来源:https://stackoverflow.com/questions/33789752/how-to-use-subreport-in-jasper