[英]Getting java.io.FileNotFoundException (classpath .jasper in NetBeans)
I have done project, my problem is put path or classpath of report that I make it. 我已经完成了项目,我的问题是我制作的报告的路径或类路径。 Sorry I am newbie around making a report. 抱歉,我是新手。 The report that I made with iReport has .jrxml extension, but NetBeans not read files .jrxml ? 我使用iReport 编写的报告具有.jrxml扩展名,但是NetBeans无法读取文件.jrxml ?
So I compiled this report to a .jasper and save this report to folder src/reports/MenuProduk.jasper
. 因此,我将此报告编译为.jasper并将其保存到文件夹src/reports/MenuProduk.jasper
。
My problem is why my Java NetBeans cann't read my report? 我的问题是为什么Java NetBeans无法读取我的报告?
My code is: 我的代码是:
public ReportViewProduk(String vName) {
initComponents();
dao = new ProdukDao();
produkList= dao.getListData();
try {
Map m;
m = new HashMap();
m.put("Print By", "Sanjaya");
jasperPrint=JasperFillManager.fillReport(getClass().getResourceAsStream("/reports/produkReport.jasper"),
m,new JRBeanCollectionDataSource(produkList));
if(PanelReport.getComponentCount()>0){
PanelReport.removeAll();
}
PanelReport.add(new JRViewer(jasperPrint));
PanelReport.updateUI();
} catch (JRException ex) {
System.out.println("Error : " + ex.getMessage());
Logger.getLogger(ReportViewProduk.class.getName()).log(Level.SEVERE, null, ex);
}
}
Check whether you jasper files are copied into "classes" dir (see the "reports" dir). 检查是否将jasper文件复制到“类”目录中(请参阅“报告”目录)。 I guess they are not copied there. 我猜他们没有被复制到那里。 Check NetBeans settings to include resource types *.jrxml and *.jasper to be copied when your project is compiled. 检查NetBeans设置,以包括在编译项目时要复制的资源类型* .jrxml和* .jasper。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.