javajasper-reports

How to save the compiled JasperReport as a .jasper in a file


I have this code. I have a jrxml file. I can create a jasperReport object successfully. But I don't know how to create jasper file from this and I want to save jasper to a file location in c drive.

JasperReport jasperReport = null;
JasperCompileManager.compileReport(getResourceAsStream("Sample_Report.jrxml"));
    try {
        jasperReport = JasperCompileManager
                .compileReport("C:\\xxx.jrxml");
        System.out.println("jasper created " + jasperReport);
    } catch (Exception e) {
        e.printStackTrace();
    }

Solution

  • The Method you want to use is

    JasperCompileManager.compileReportToFile("C:\\xxx.jrxml", "C:\\xxx.jasper");