3

I have created one project in java with the help of Netbeans IDE. I am using Jasper Reports as a reporting tool. When I run my project in netbeans the reports run properly. But when I run my program with jar file the reports don't work. It is showing jasper report error. I have added all the jar files that are required for building a project jar file. Is there any way to integrate a jasper reports jars with my project jar?

thanks in advance Rohan

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Rohan Bomle
  • 51
  • 1
  • 2
  • 6

3 Answers3

0

you have to check your manifiest and add libraries if it miss some one:

`Class-Path: lib/jasperreports-5.0.0.jar lib/jasperrepo
 rts-chart-themes-5.0.0.jar lib/jasperreports-core-renderer.jar lib/ja
 sperreports-expressions-0.0.3.jar lib/jasperreports-exprfunctions-0.0
 .3.jar lib/jasperreports-extensions-3.5.3.jar lib/jasperreports-fonts
 -5.0.0.jar lib/jasperreports-htmlcomponent-4.7.1.jar lib/jasperreport
 s-json.jar lib/jasperreports-jtidy-r938.jar lib/com-jaspersoft-irepor
 t-components.jar lib/com-jaspersoft-ireport-jasperserver.jar lib/com-
 jaspersoft-ireport.jar lib/com-jaspersoft-jrx.jar lib/conexion.jar li
 b/spring-core-3.2.2.RELEASE.jar lib/commons-logging-1.1.1.jar lib/com
 mons-beanutils-20030211.134440.jar lib/commons-collections-20040616.j
 ar lib/commons-digester-2.1.jar lib/spring-beans-3.2.2.RELEASE.jar li
 b/groovy-all-2.1.1.jar lib/itext-4.2.0.jar lib/commons-javaflow-20060
 411.jar`
0

Problem is not with your code... Just add following libraries. Don't use latest jasper libraries. that is the reason to not load your reports through jar executable. (use ireport 5.5.0 libraries). Code i used shown below

String report2 = "H:\\Higher Diploma Project\\FinalHD\\src\\Reports\\SalesInvoiceCustomerCopy.jrxml";
JasperReport rep2 = JasperCompileManager.compileReport(report2);
JasperPrint rep_print2 = JasperFillManager.fillReport(rep2,null,connect);
JasperPrintManager.printReport(rep_print2,false);

String report = "H:\\Higher Diploma Project\\FinalHD\\src\\Reports\\SalesInvoice.jrxml";
JasperReport rep = JasperCompileManager.compileReport(report);
JasperPrint rep_print = JasperFillManager.fillReport(rep,null,connect);
JasperPrintManager.printReport(rep_print,false);]
beresfordt
  • 5,088
  • 10
  • 35
  • 43
0

Possibly you haven't put the required libraries into the Class-path attribute of your manifest file?

Class-Path :

The value of this attribute specifies the relative URLs of the extensions or libraries that this application or extension needs. URLs are separated by one or more spaces. The application or extension class loader uses the value of this attribute to construct its internal search path.

Read this tutorial about manifest files.

And there's an ant task for creating one on the fly.

Daniel Hiller
  • 3,415
  • 3
  • 23
  • 33