2005 IR Help Posted August 26, 2006 Share Posted August 26, 2006 By: mpisano - mpisano loading .jasper files saved on .jar 2004-08-06 08:18 Hi all, does anybody could tell me if it is possible to pack .jasper files on jar files and then to load them from there (the jar file without unpacking) in order to have all the resources on one jar file. Thanks in advance. Mauro. By: rajukalady - rajukalady RE: loading .jasper files saved on .jar 2004-08-07 03:12 Hi all I am new to java and jasper report.How can i pack jasper files in a jar By: Emmanuel Okyere - eokyere RE: loading .jasper files saved on .jar 2004-08-06 10:49 simply put your file in a folder you can track from the jar and use the JRLoader class to load it; for instance if my report is "Report.jasper" and the path to it from the root of the jar file is "report/Report.jasper", i'll simply do JRLoader.loadObjectFromLocation("report/Report.jasper") HTH - eokyere By: HungABD - hungabd RE: loading .jasper files saved on .jar 2004-08-16 02:03 Hi Emmanuel Okyere Can you explani deatail for me what the way to call JRLoader class for display *.jasper from jar file and what the way to use parameter in. Thank you By: C-Box - c-box RE: loading .jasper files saved on .jar 2004-08-16 03:22 Well try this to load a jasper-file from your jar-archive: JasperReport jr = null; String reportDir = new String("/reports/templates/"); // your directory structure within the jar - see with the class beyond String reportFileName = new String ("YourTemplateReportName"); String reportExt = new String(".jasper"); String reportString = ((DruckDokument.class.getPackage().getName()).replace('.','/')+reportDir+reportFileName+reportExt).toLowerCase(); // DruckDokument is my current class i'm loading the reports from just to get my package-structure you must place your own class here Class c = getClass(); ClassLoader cl = c.getClassLoader(); URL u = cl.getResource(reportString); if (u != null){ InputStream is = u.openStream(); jr = (JasperReport) JRLoader.loadObject(is); }else throw new AfpsException("Could not load PrintTemplate from JAR-Archive ("+reportString+")!"); hth C-Box Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now