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.
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.
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: