When wanting to run a report made with iReport (the first one I do), it throws me the following error FileNotFoundException. I understand that it does not find the way to the file, but it is not clear to me how specify it, try in several ways, here are the last ones, so if anyone can tell me what I'm doing wrong. First Attempt:
try {
String compiledReport = "d:\java\movimientosporfecha.jasper";
JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(compiledReport);
Map parametros = new HashMap();
parametros.put("pdefec", this.defec);
parametros.put("phafec", this.hafec);
JasperPrint j = JasperFillManager.fillReport(report, parametros, connection);
JasperViewer jv = new JasperViewer(j, false);
jv.setTitle("Reporte de Movimientos por Fecha");
jv.setVisible(true);
} catch (Exception e){
System.out.println(e);
}
Second Attempt:
try {
String compiledReport = "d:\java\movimientosporfecha.jasper";
URL in = this.getClass().getResource(compiledReport);
JasperReport report = (JasperReport) JRLoader.loadObject(in);
Map parametros = new HashMap();
parametros.put("pdefec", this.defec);
parametros.put("phafec", this.hafec);
JasperPrint j = JasperFillManager.fillReport(report, parametros, connection);
JasperViewer jv = new JasperViewer(j, false);
jv.setTitle("Reporte de Movimientos por Fecha");
jv.setVisible(true);
} catch (Exception e){
System.out.println(e);
}
In both cases, it sends me the same error!
The report exists in the folder!
And also try different ways to specify the route, for example:
String compiledReport="d: \ java \ movementsbydate.jasper";
String compiledReport="d: //java//movimientosporfecha.jasper";
Either by specifying the full path to the folder of the reports in the project: "D: //Java//GastosJSF2//src//main//java//reportes//movimientosporfecha.jasper"
Never Works!