JasperReport in java jar file


I have a java .jar file that was created using Eclipse.  I have two Jasper reports

which run perfectly when I am inside the Eclipse IDE, but after exporting the program

to a .jar file, the reports will not show any data.  I get no errors.  When I press the button to generate the report, I get nothing.

The code for the button is below.  These are compiled jasper files.  They were compiled using iReports 5.1

I am using Jasper Reports Library 5.1.2.  

I am running Eclipse 4.2.0 on Windows 7 Enterprise

I have looked all over the internet with no luck.  As I said earlier, everything works fine in Eclipse, but not from the standalone .jar file.

I sure would be happy if someone could tell me what I am missing here.




Connection connect;

String fileName = "All_Dist_By_Del_dt.jasper";
// String outFileName = "DistByRecipient.pdf";
HashMap<String, Object> hm = new HashMap<String, Object>();
try {
// Setup the connection with the DB
connect = DriverManager.getConnection("jdbc:mysql://localhost/database", "user", "password");
JasperPrint print = JasperFillManager.fillReport(fileName, hm,connect);
// view report in the JasperViewer
JasperViewer.viewReport(print, false);
} catch (JRException f) {
JOptionPane.showMessageDialog(null, "Jasper Reports error: "
+ f.getMessage(), "Report Error",
} catch (ClassNotFoundException e2) {
// TODO Auto-generated catch block
} catch (SQLException e1) {
// TODO Auto-generated catch block


monty.love's picture
Joined: Jun 25 2013 - 9:06am
Last seen: 4 years 3 months ago

0 Answers:

No answers yet