FileNotFoundException Jasperreports

人盡茶涼 提交于 2019-12-20 03:52:32

问题


  1. I am loading an jrxml file in netbeans which is succefully loaded.
    But when I'm deploying it as a jar file it gives the below error:

Error

    net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: src \Reports\print.jrxml(The system cannot find the path specified)

Code

try
{   
 jasperdesign=JRXmlLoader.load("src/Reports/print.jrxml");
} 
catch(Exception error) 
{
Notify.showMessageDialog(null, ""+error+"", "Error Loading Appointment JasperForm", Notify.ERROR_MESSAGE); 
}

回答1:


I doubt the dir named srcis in you jar

try getting an InputStream using ClassLoader's method getResourceAsStream to your packed jrmx file and pass it to the JRXmlLoader's load method that takes an InputStream as argument.

the argument for getResourceAsStream should be the full qualified name of the jrxml in your jar. That is, including the package name.



来源:https://stackoverflow.com/questions/15175899/filenotfoundexception-jasperreports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!