1
resposta

Exception in thread "main" net.sf.jasperreports.engine.JRException

Estou tentando compilar um arquivo jrxml com o java, mas não tá dando, estou fazendo o curso jasper reports: relatórios com java, nesta aula: Gerando PDF e outras saídas na aplicação Java, segue meu código e a stacktrace:

package br.com.caelum.financas.relatorio;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
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.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRXlsExporter;
import br.com.caelum.financas.ConnectionFactory;

public class TesteGeraRelatorio {

    public static void main(String[] args) throws SQLException, JRException, FileNotFoundException {

        JasperCompileManager.compileReportToFile("financas.jrxml"); 

        Connection conexao = new ConnectionFactory().getConnection();

        conexao.close();
    }
}

Exception in thread "main" net.sf.jasperreports.engine.JRException: Error compiling report java source files : C:\Users\Intera-PC\Desktop\cap5-movimentacoes\movimentacoes\financas_1509989944755_517316.java 
    at net.sf.jasperreports.engine.design.JRJavacCompiler.compileClasses(JRJavacCompiler.java:106)
    at net.sf.jasperreports.engine.design.JRAbstractClassCompiler.compileUnits(JRAbstractClassCompiler.java:77)
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:201)
    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:240)
    at net.sf.jasperreports.engine.JasperCompileManager.compileToFile(JasperCompileManager.java:156)
    at net.sf.jasperreports.engine.JasperCompileManager.compileToFile(JasperCompileManager.java:115)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:415)
    at br.com.caelum.financas.relatorio.TesteGeraRelatorio.main(TesteGeraRelatorio.java:23)
Caused by: java.io.IOException: Cannot run program "javac": CreateProcess error=2, O sistema não pode encontrar o arquivo especificado
    at java.lang.ProcessBuilder.start(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at net.sf.jasperreports.engine.design.JRJavacCompiler.compileClasses(JRJavacCompiler.java:75)
    ... 7 more
Caused by: java.io.IOException: CreateProcess error=2, O sistema não pode encontrar o arquivo especificado
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    ... 11 more
Picked up _JAVA_OPTIONS: -Xmx512m
1 resposta

Opa, parece que você não passou o caminho correto do arquivo :). Experimenta o caminho absoluto?