-1

I am trying to use my NetBeans to print pdf file from jasper report but it gives a file not found exception

 try {
        OracleDataSource ods = new OracleDataSource();
        ods.setURL("gdbc:oracle:thin:@localhost:1521:orcl");
        ods.setUser("user");
        ods.setPassword("123456");
        InputStream s= new FileInputStream(new File("Tree.jrxml"));
        JasperDesign ds = new FXMLLoader().load(s);
        JasperReport jr = JasperCompileManager.compileReport(ds);
        HashMap parameters = new HashMap<String, String>();
        parameters.put("id",idtxt.getText());
        JasperPrint jp = JasperFillManager.fillReport(jr, parameters ,ods.getConnection());
        OutputStream out = new FileOutputStream (new File ("REP.pdf"));
        JasperExportManager.exportReportToPdfStream(jp, out);
        ods.getConnection().close();
        s.close();
        out.close();

    }catch(Exception x){
        System.out.println(x.toString());
    }


 the exception :

java.io.FileNotFoundException: Tree.jrxml (The system cannot find the file specified)

all files needed in src folder and all libraries imported as well

  • src

     Myrep.java
    
     Tree.jrxml
    

1 Answers1

0

Clearly it's the wrong path. Try to put Tree.jrxml in resource marked directory:) In Java usually src/main/resources, and your code is in src/main/java dir.

white-hack
  • 25
  • 1
  • 4