I want to make report using Jasper , so I make .jrmxl file as resource. And I used this code to read that .jrxml :
JasperDesign jasperDesign = JasperManager.loadXmlDesign(new File(".").getAbsolutePath()+ "\\report\\reportPdf.jrxml");
That code ran well , and the report also appears .
My problem is when I export the program into .jar file , error appears , and It says "unknown resource" in line code above. So i am worried why this error is occuring ?
The report will now be an embedded resource, and not accessible by File
.
You need to gain an URL
, get an InputStream
for it and call loadXmlDesign(InputStream)
(or the non-deprecated variant - see the docs).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.