0
I have a java class in netbenas that was to generate a report, according to the Service Order (ID) entered by the user. But Netbeans returns an error "File or report not found".
private void imprimir() {
    int confirma = JOptionPane.showConfirmDialog(null, "Deseja realmente viusalizar o relatório?", "Atenção", JOptionPane.YES_NO_OPTION);
    if (confirma == JOptionPane.YES_OPTION) {
        Map map = new HashMap();
        map.put("cod_solicitante", txtCod.getText());
        JasperReport relatorio;
        JasperPrint impressao;
        try {
            if (!txtCod.getText().equals("")) { // verifica se não está vazia
                relatorio = JasperCompileManager.compileReport(new File("").getAbsolutePath() + "/home/joao/Documentos/NetBeansProjects/ProjetoTCC/src/MyReports/RelatorioRequerente.jrxml");
                impressao = JasperFillManager.fillReport(relatorio, map, conexao); //cria janela com relatório
                JasperViewer viewer = new JasperViewer(impressao, false);
                viewer.setTitle("Requerente de Alvará");
                viewer.setVisible(true);
            } else {
                JOptionPane.showMessageDialog(null, "Selecione um  para impressão");
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "ERRO: " + e.getMessage());
        }
    }
}
I have another class that takes all the records and generates normal report
int confirma = JOptionPane.showConfirmDialog(null, "Deseja viusalizar o relatório?", "Atenção", JOptionPane.YES_NO_OPTION);
    if (confirma == JOptionPane.YES_OPTION) {
        try {
            JasperPrint print = JasperFillManager.fillReport("/home/joao/Documentos/NetBeansProjects/ProjetoTCC/src/MyReports/RelatorioVistoria.jasper", null, conexao); // pega o relatorio
            JasperViewer.viewReport(print, false);//abre em modo de visualização
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "ERRO: " + e.getMessage());
        }
    }
Any tips on how to proceed?
Did you see that in
JasperCompileManager.compileReportyou’re passing a path that makes no sense?– Jefferson Quesado
Do you have any suggestions to change this path?
– João Paulo da Mata Mendes
Have you tried that?
new File("/home/joao/Documentos/NetBeansProjects/ProjetoTCC/src/MyReports/RelatorioRequerente.jrxml").getAbsolutePath()?– Roknauta