Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FileNotFoundException when running application using jasperreports

 
Joshua Ebarvia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello! I have compiled my java application done using Netbeans and it generated a .jar file.

My application is able to load the jasper reports if i compile and run it in my local machine.

However, if i distribute my application to another machine, the jasper report cannot be loaded and returns jrexceptions: java.io.filenotfoundexception: c:/reports/reportInvestment.jasper

my code is this using the



Please help
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JasperManager method fillReport is overridden and can take as the first parameter, a String Object (Which you are using), an InputStream or a JasperReport object.

Using the String method requires the report template to be on the file system. When you do your deployment, you need to create report directory on the C drive of the target machine and put a copy of reportInvestment.jasper there.

A better way to do this to make deployments easier is to include /reports/reportInvestment.jasper in your Jar file and change your code to :

 
Joshua Ebarvia
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have followed your instructions and it WORKS.

Thanks Carl.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic