java - jasper reports file not found exception need help please -
java - jasper reports file not found exception need help please -
hi friends trying pass couple of parameter through hashmap jasper report, getting file not found exception file placed under netbeans project folder,the below java code
try{ hashmap hmp = new hashmap(); hmp.put("mytin", m_t_n); hmp.put("cname", c_n_m); hmp.put("invno", c_in); hmp.put("ctin", c_t); hmp.put("date", c_d); hmp.put("time", c_m); hmp.put("gtot", gt); hmp.put("dis", dcn); hmp.put("adj", amtn); hmp.put("fin", fn_am); jasperreport jrpt = null; string srcd="report1.jrxml"; jasperprint jp; //jrpt = jaspercompilemanager.compilereport(getclass().getresource(srcd)); jrpt = (jasperreport)jrloader.loadobject(new file(srcd)); jp=jasperfillmanager.fillreport(jrpt,hmp, drivermanager.getconnection("jdbc:mysql://localhost:3306/billing", "root", "")); jasperviewer jv = new jasperviewer(jp,false); jv.setfitwidthzoomratio(); jv.setvisible(true); } catch(exception er){ }
the error is
run: java.io.filenotfoundexception: report1.jrxml net.sf.jasperreports.engine.jrexception: java.io.filenotfoundexception: report1.jrxml
kindly help me resolve error in advance
let's assume class file , report1.jrxml
stored within same bundle within project...
src/some/package/name/report.java src/some/package/name/report1.jrxml
then, should able utilize getclass().getresource("report1.jrxml")
obtain url
reference resource
if work, need seek getclass().getresource("/some/package/name/report1.jrxml")
. if fails, there wrong file. either it's not think or corrupted in way...
a jrxml
file xml
file used jasperreports, needs compiled first before can used...
try{ hashmap hmp = new hashmap(); hmp.put("mytin", m_t_n); hmp.put("cname", c_n_m); hmp.put("invno", c_in); hmp.put("ctin", c_t); hmp.put("date", c_d); hmp.put("time", c_m); hmp.put("gtot", gt); hmp.put("dis", dcn); hmp.put("adj", amtn); hmp.put("fin", fn_am); jasperreport jrpt = null; string srcd="report1.jrxml"; jasperprint jp; jrpt = jaspercompilemanager.compilereport(getclass().getresource(srcd)); //jrpt = (jasperreport)jrloader.loadobject(new file(srcd)); jp=jasperfillmanager.fillreport(jrpt,hmp, drivermanager.getconnection("jdbc:mysql://localhost:3306/billing", "root", "")); jasperviewer jv = new jasperviewer(jp,false); jv.setfitwidthzoomratio(); jv.setvisible(true); } catch(exception er){ er.printstacktrace(); }
java swing jasper-reports
Comments
Post a Comment