• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

FileNotFoundException when running application using jasperreports

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have followed your instructions and it WORKS.

Thanks Carl.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic