Hi, I'm using JasperReports in netbeans, on Ubuntu. When I execute my java application on netbeans I have no problem saving the reports, but when I clean and build the program, and run it from the .jar, the program can't save the reports. I don't know if that's because of the folder permissions or the jvm used, please, I need urgent help with this.

5 Years
Discussion Span
Last Post by Kevingon

Actually it doesn't throws any exception, but I use this method to show the report:

try {
                  File path = new File (outFileNamePDF);
             }catch (IOException ex) {

And there's where I get the exception, a file not found one.

Just remember that this works on netbeans, but not when executed from the .jar.


What should it be, and where do I check that? I'm kind of a newbie in linux, so tell me what commands should I use on terminal or what should I use on the GUI. Are you talking about the folder permissions? because the file is created from code, with:


And if the problem is that permission stuff, why netbeans does have permission? this is a portable program, so it must work on any computer. Thanks for the help.

Edited by Kevingon: Bad spelling


From your code above, it looks like you're showing the file name in a dialog just before opening


Can you check the read/write permissions on that location?

Netbeans created build and dist folders for the files that it generates. I'm not sure how ownership and permissions are set on those. I've never used Ubuntu in my life, so I couldn't tell you how to check them.


I do show the path before trying to open it, but I don't think that the dist or build folders are the problem as I'm storing the reports in a Report folder, inside the project folder. I made a method to make my program identify if it's running from windows or linux, and if it's running from netbeans or from the .jar, and it's capable of getting the correct path for the reports and my "pseudo-database". The path got inside netbeans, and the path got from the .jar (at executing) are exactly the same, but it only saves the report if it's running inside netbeans, so I doubt it is a permission problem. Thanks


I solved it, it wasn't a permission problem, it was a jar problem. I'll explain:
When netbeans executes the program, it runs from the sources folders, so the report.jasper it's a normal file. When it runs from the .jar, it is inside the jar, and the files inside the jar can't be modified. I think that the jvm can't use the .jasper files inside the jar to make a report.

To solve this just put all the .jasper and other files like images used, inside a .jar, and import it to the project, then change this:

This is how I recovered the .jasper file before:

route = getClass().getResource("/org/almg/report/report1.jasper").getFile();

instead of it just import the jar with the report files to the project, don't use any import in the class and put something like this:


I just put that because it isn't inside of any folder. That works perfectly for me now. But I'd like someone to explain this better. Thanks for the help Ezzaral.

Edited by Kevingon: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.