我正在尝试使用Java应用程序来生成在iReport中创建的报告。我的代码如下:
Connection conn = (Connection) new OracleCon().getConnection();
System.out.println(conn);
Map<String, Object> param = new HashMap<String, Object>();
param.put("PARCLOCADOR", "47");
System.out.println(param);
try {
//conectar com o banco de dados
JasperPrint jp = JasperFillManager.fillReport("src/report/RelacaoRendimentos-DIMOB_NEW.jasper", param, conn);
System.out.println(jp);
JasperViewer jw = new JasperViewer(jp);
jw.setVisible(true);
} catch (JRException e) {
e.printStackTrace();
}
我有这些例外:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at net.sf.jasperreports.engine.JasperFillManager.<clinit>(JasperFillManager.java:81)
at com.geraRelatorio.CreateReport.main(CreateReport.java:46)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
它可以工作到这里:“ System.out.println(param);”
我正在使用的所有库都在这里:
ojdbc8.jar
SankhyaW-extensions.jar
SWService.jar
jasperreports-6.7.0\dist\jasperreports-6.7.0.jar
jasperreports-6.7.0\dist\jasperreports-fonts-6.7.0.jar
jasperreports-6.7.0\dist\jasperreports-javaflow-6.7.0.jar
commons-logging-1.1.2.jar
groovy-all-2.1.3.jar
commons-logging-1.1.jar
commons-collections4-4.3.jar
commons-collections4-4.3-javadoc.jar
commons-collections4-4.3-sources.jar
commons-collections4-4.3-tests.jar
commons-collections4-4.3-test-sources.jar