Jump to content
Changes to the Jaspersoft community edition download ×

..:: HOW TO RUN .jasper FROM SWING ::..


som15129

Recommended Posts

Hi,

 

I a new user in iReport dont know how to run *.jasper (generated by iReport) reporting files from Swing/Java . Hve U any sample code plzz give me the code.

======================================

I execute a prog. At compile time its okey but at runtime it gives too errors...

 

====MY CODE======

 

import net.sf.jasperreports.engine.*;

import net.sf.jasperreports.engine.export.*;

import java.util.*;

public class JasperTest

{

public static void main(String[] args)

{

String fileName = "test.jasper";

String outFileName = "test.pdf";

HashMap hm = new HashMap();

hm.put("name","Som15129");

try

{

JasperPrint print = JasperFillManager.fillReport(

fileName,

hm,

new JREmptyDataSource());

JRExporter exporter = new net.sf.jasperreports.engine.export.JRPdfExporter();

exporter.setParameter(

JRExporterParameter.OUTPUT_FILE_NAME,

outFileName);

exporter.setParameter(

JRExporterParameter.JASPER_PRINT,print);

exporter.exportReport();

System.out.println("Created file: " + outFileName);

}

catch (JRException e)

{

e.printStackTrace();

System.exit(1);

}

catch (Exception e)

{

e.printStackTrace();

System.exit(1);

}

}}

 

...........Exceptions..........

 

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lo

gging/LogFactory

at net.sf.jasperreports.engine.fill.JRFillTextElement.<clinit>(Unknown Source)

at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getTextField(Unk

nown Source)

at net.sf.jasperreports.engine.base.JRBaseTextField.getCopy(Unknown Source)

at net.sf.jasperreports.engine.fill.JRFillElementGroup.<init>(Unknown Source)

at net.sf.jasperreports.engine.fill.JRFillElementContainer.<init>(Unknow

n Source)

at net.sf.jasperreports.engine.fill.JRFillBand.<init>(Unknown Source)

at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getBand(Unknown

Source)

at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(Unknown Source)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(Unknown Source)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(Unknown Source)

at net.sf.jasperreports.engine.fill.JRFiller.createFiller(Unknown Source

)

at net.sf.jasperreports.engine.fill.JRFiller.fillReport(Unknown Source)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(Unknown Source)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(Unknown Source)

at JasperTest.main(JasperTest.java:14)

Press any key to continue . . .

Post edited by: som15129, at: 2006/10/31 07:41

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...