Java program does not find the Jasper report path

Asked

Viewed 454 times

3

I made a small program in java to generate budget reports, I used for both Jasper Ireport, made, tested, generated the budgets all running on my computer. When I installed it on a friend’s computer it worked all right except the reports, it doesn’t even appear blank, it looks like this:

inserir a descrição da imagem aqui

In the code, the image path, it seems, is set correctly.

public void imprimeRelatorio() {

        ConexaoMySql co = new ConexaoMySql();
        co.setUrl("jdbc:mysql://localhost:3306/poc");
        co.setUsuario("root");
        co.setSenha("");

         String src = "C:\\orcamento.jasper";


        Map<String, Object> parametros = new HashMap<String, Object>();
        parametros.put("id",(Integer.parseInt(inpId.getText())));
          System.out.println("parametros="+parametros);


      JasperPrint jasperPrint = null;
        try {
            jasperPrint = JasperFillManager.fillReport(src, parametros, co.getConnection());
        } catch (JRException ex) {
            Logger.getLogger(TelaControle.class.getName()).log(Level.SEVERE, null, ex);
        }
        JasperViewer view = new JasperViewer(jasperPrint, false);
        view.setVisible(true);
        System.out.println("view" +view);

    }

inserir a descrição da imagem aqui

I ran by cmd to see the output and actually the image path seems to be correct.

inserir a descrição da imagem aqui

The strange thing is that my computer works normally.

1 answer

2


Two were the mistakes: as the windows of that machine is configured not to show the file extension, the file name was divergent, so I renamed the file to only orcamento.

The second error was in the report file itself because it contained a logo that was with the path of the folders of the other computer. When I fixed this, it solved the problem and generated the reports normally. Thank you.

Browser other questions tagged

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