I'm trying to make a report with JasperReports containing the result of the queries to a database. I followed some tutorials and I wrote the code. The part which the database connection it's ok, it works:
"Get connection ... Get connection oracle.jdbc.driver.************ Done!", but when I'm trying to run the class with the report, I face some exceptions:
1) Exception in thread "main" net.sf.jasperreports.engine.JRException: Error compiling report java source files : E:\Fc\Java\hws\L9again\StyledTextReport_1462019818479_424906.java;
2)Caused by: java.io.IOException: Cannot run program "javac": CreateProcess error=2, The system cannot find the file specified;
3)Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified.
My code for the part with the report is:
package org.o7;
import java.io.File;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.export.ExporterInput;
import net.sf.jasperreports.export.OutputStreamExporterOutput;
import net.sf.jasperreports.export.SimpleExporterInput;
import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;
import net.sf.jasperreports.export.SimplePdfExporterConfiguration;
public class JavaCallJasperReport {
public static void main(String[] args) throws JRException,
ClassNotFoundException, SQLException {
String reportSrcFile = "C:/jasperreport/StyledTextReport/StyledTextReport.jrxml";
// First, compile jrxml file.
JasperReport jasperReport = JasperCompileManager.compileReport(reportSrcFile);
Connection conn = ConnectionUtils.getConnection();
// Parameters for report
Map<String, Object> parameters = new HashMap<String, Object>();
JasperPrint print = JasperFillManager.fillReport(jasperReport,
parameters, conn);
// Make sure the output directory exists.
File outDir = new File("C:/jasperoutput");
outDir.mkdirs();
// PDF Exportor.
JRPdfExporter exporter = new JRPdfExporter();
ExporterInput exporterInput = new SimpleExporterInput(print);
// ExporterInput
exporter.setExporterInput(exporterInput);
// ExporterOutput
OutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(
"C:/jasperoutput/FirstJasperReport.pdf");
// Output
exporter.setExporterOutput(exporterOutput);
//
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
exporter.setConfiguration(configuration);
exporter.exportReport();
System.out.print("Done2!");
}
}
Can anyone tell me what can I do to solve this?
please try putting jdt-compiler.jar in you classpath.let me know if you have problem doing that