Report not found when running . jar

Asked

Viewed 84 times

-1

In netbeans it finds the normal report, but when I go through the jar, it is not finding.

I have seen some topics here about this problem, but still I could not solve, because they say that is just take the "src" the path of the folder where the report is allocated.

Follows my code:

Connection conn = new SQLConnection().java_db();
if(!jComboBox1.getSelectedItem().equals("Selecione...")&&procurar1.getDate()!= null && procurar2.getDate()!=null){
Map p = new HashMap();
p.put("tipoteste", jComboBox1.getSelectedItem());
p.put("dataini", procurar1.getDate());
p.put("datafim", procurar2.getDate());
JasperReport relatorio;
JasperPrint impressao;

try {
    relatorio = JasperCompileManager.compileReport(new File("").getAbsolutePath()
            + "/Relatorios/reprovadosgeral.jrxml");

    impressao = JasperFillManager.fillReport(relatorio, p, conn);
    JasperViewer view = new JasperViewer(impressao, false);
    view.setTitle("Relatório Reprovados");
    view.setVisible(true);


} catch (Exception e) {

}
}else
{
    JOptionPane.showMessageDialog(null, "Preencha todos os campos");
}
}

1 answer

-2

Depending on the environment where you are running the . jar, can be a problem as to the folder orientation, while Linux uses "/" in Windows "\".

See more in Long live Linux.

  • 2

    This link may be a good suggestion, but your reply will not be valid if one day the link crashes. In addition, it is important for the community to have content right here on the site. It would be better to include more details in your response. A summary of the content of the link would be helpful enough! Learn more about it in this item of our Community FAQ: We want answers that contain only links?

  • The bars are correct yes, because by the IDE it performs normally..

  • @Gabrielbispo no, they are not. Java itself has a tool to avoid going through this situation. Use File.separator. The Jasper interpreter cannot decipher the computer’s OS, so you have to let java check it first.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.