我在需要碧玉报告一个项目,我已经使用下述代码片段,查看在NetBeans 6.1的报告(最初产生和使用的iReport 3.6.0编译)的报告,我的要求是用打印此报告一个简单的Swing应用程序。
的代码片断:
public class JasperCheck {
public static void main(String[] args) {
String reportSource = "E:/Projects/report.jrxml";
String reportDest = "E:/Projects/report.html";
Map<String, Object> params = new HashMap<String, Object>();
try {
JasperReport jasperReport = JasperCompileManager.compileReport(reportSource);
JasperPrint jasperPrint =
JasperFillManager.fillReport(jasperReport, params, new JREmptyDataSource());
JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest);
JasperViewer.viewReport(jasperPrint);
} catch (JRException ex) {
System.out.println(ex);
}
}
}
但是,当我运行这个它给我想不出一个例外。
Exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:157)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForName(JRClassLoader.java:115)
at net.sf.jasperreports.engine.JasperCompileManager.getCompiler(JasperCompileManager.java:511)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:215)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:148)
at src.JasperCheck.main(JasperCheck.java:31)
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.control.CompilationFailedException
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 8 more
Java Result: 1
谢谢。