java 无法运行 Jasper 报告:系统找不到指定的文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1248237/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 15:48:35  来源:igfitidea点击:

Unable to run Jasper report : The system cannot find the file specified

javanetbeansjasper-reports

提问by Mohanish Timble

I have the reports in reports\templates\Contractor_Bill.jrxmland the results in reports\results\. It works fine in Netbeans 6.5, but when i copy the distfolder containing exec jar file to a new place and run the jar it throws this exception.

我有报告reports\templates\Contractor_Bill.jrxml和结果 reports\results\。它在 Netbeans 6.5 中工作正常,但是当我将dist包含 exec jar 文件的文件夹复制到新位置并运行 jar 时,它会引发此异常。

I also created the report folder in the new place, and it still generates the same exception.

我还在新地方创建了报告文件夹,它仍然生成相同的异常。

Aug 5, 2009 10:11:58 PM cbs.ui.ReportUI GenerateReport
SEVERE: null
net.sf.jasperreports.engine.JRException: Error compiling report java source files : C:\Documents and Settings\Mohanish Timble\Desktop\sw\Contractor_Bill_old_1249490518017_973633.java
        at net.sf.jasperreports.engine.design.JRJavacCompiler.compileClasses(JRJavacCompiler.java:93)
        at net.sf.jasperreports.engine.design.JRAbstractClassCompiler.compileUnits(JRAbstractClassCompiler.java:67)
        at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:190)
        at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:220)
        at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:153)
        at cbs.ui.ReportUI.GenerateReport(ReportUI.java:202)
        at cbs.ui.ReportUI.btnGenerateBillActionPerformed(ReportUI.java:151)
        at cbs.ui.ReportUI.access0(ReportUI.java:38)
        at cbs.ui.ReportUI.actionPerformed(ReportUI.java:85)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.io.IOException: Cannot run program "javac": CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at net.sf.jasperreports.engine.design.JRJavacCompiler.compileClasses(JRJavacCompiler.java:62)
        ... 33 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        ... 37 more
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java: 138)
        at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:57)
        at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)
        at cbs.ui.ReportUI.GenerateReport(ReportUI.java:218)
        at cbs.ui.ReportUI.btnGenerateBillActionPerformed(ReportUI.java:151)
        at cbs.ui.ReportUI.access0(ReportUI.java:38)
        at cbs.ui.ReportUI.actionPerformed(ReportUI.java:85)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

回答by Mohanish Timble

Include the Jar jasper-compiler-jdt in the lib folder

在 lib 文件夹中包含 Jar jasper-compiler-jdt

回答by Petter Friberg

For versione of jasper-reports >= 6.0.0, the jar used to compile is called

对于jasper-reports >= 6.0.0的versione,用于编译的jar被调用

ecj-x.x.x.jar

See maven repoto get correct version number of ecj for relative version of jasper reports.

请参阅maven repo以获取 ecj 的正确版本号以获取 jasper 报告的相关版本。