Can’t load jrxml located in jar file via JRXmlLoader: getting [duplicate]

/reports/teacherPay.jrxml is an absolute file path, meaning, go to the root of the current drive and find the file teacherPay.jrxml in the reports directory…

Which, if I read your question correctly, isn’t what you want

Instead, try loading the report as a resource (given the fact that you state that it’s within a package

JasperDesign jd  = JRXmlLoader.load(getClass().getResource("/reports/teacherPay.jrxml"));

If the report isn’t packaged within your application context, then you will need to use a relative path instead, for example.

JasperDesign jd  = JRXmlLoader.load("reports/teacherPay.jrxml");

Now, having said that. Unless you are making dynamic changes at runtime, you shouldn’t be loading the jrxml file, but instead, should have pre-compiled the file and should be loading the .jasper file instead. This will be faster and generally less error prone…

Leave a Comment