简体   繁体   中英

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 ?

So I compiled this report to a .jasper and save this report to folder src/reports/MenuProduk.jasper .

My problem is why my Java NetBeans cann't read my report?

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). 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM