Zweli Posted March 25, 2011 Share Posted March 25, 2011 Hello, I am new to Jasper Reports and I am not sure where to store my ".jrxml" and ".jasper" files.In my project, I have stored all my files in the src file folder, including the ".jrxml" and ".jasper" files but i receive an exception.Can someone please tell/explain what i could be doing wrong and a solution for it, also where to store my files.thank youMy code snippet is as follows : Code: try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection con =DriverManager.getConnection("jdbc:sqlserver://localhost;" + "instanceName=SQLEXPRESS2008;databaseName=OMA2008_DB;", "sa", "admin2008"); JasperReport jasperReport = JasperCompileManager.compileReport("newReport.jrxml"); JasperPrint print = JasperFillManager.fillReport(jasperReport, parameter, con); JRViewer viewer = new JRViewer(print); Container c = getContentPane(); c.setLayout(new BorderLayout()); c.add(viewer); } catch (ClassNotFoundException cnfe) { cnfe.printStackTrace(); System.out.println("Error: " + cnfe.toString()); } catch(SQLException sqle) { System.out.println("Error: " + sqle.toString()); sqle.printStackTrace(); } catch(JRException jre) { System.out.println("Error: " + jre.toString()); jre.printStackTrace(); } catch (JRRuntimeException e) { System.out.println("Error: " + e.toString()); } Link to comment Share on other sites More sharing options...
mdrg Posted March 25, 2011 Share Posted March 25, 2011 First, it's hard to find a situation where makes sense to compile a report (jrxml) file in your running application, and it seems your application have no need for this. You should keep the 'jrxml' files as part of your project, but only include the 'jasper' into the classpath, as it is already compiled and ready to use.As an example, in my project I keep the 'jasper' files into a 'resources' source folder, which will be included in my packaged application, so it can be easily loaded. The snippet below should make it clearer.So, put the 'jasper' files in your application classpath, and leave the source files (jrxml) out, as they will be useless for your running application. Code: Post Edited by mdrg at 03/25/2011 16:40 Link to comment Share on other sites More sharing options...
jasti Posted August 22, 2012 Share Posted August 22, 2012 hi...i have a problem that is where to store jrxmls& jaspers in our running application...from the above discussed topics u asked to save only jasper...so i created a package in src and kept .jasper files in it...but i got file not found exception.should we change default expression in jrxmls also?if we have to change how and where we have to change it?initially i stored my jrxmls&.jasper in jasperreports folder in c drive. please do help...its really important and urgent....thanks in advance...Code:<defaultValueExpression><![CDATA["C:\\JasperReports\\"]]></defaultValueExpression> 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