Discussion:
Using Netbeans and JasperReports
Enock Mangunda
2008-03-07 14:23:48 UTC
Permalink
Hie,

I am failing to get my application to view JasperReports reports. I am
quite lost so can someone send me a simple project that clearly shows
how to incorporate JasperReports into a Java project. I have gone
thruogh the JasperReports tutorial but have had no success.



Nyaradzo Enock Mangunda

Comprint Support Team

EBI Zimbabwe (Pvt) Limited
Sergio Samayoa
2008-03-07 14:45:24 UTC
Permalink
Are you using iReport for NB?



http://www.jasperforge.org/jaspersoft/opensource/business_intelligence/irepo
rt/page.php?name=nb-0.9.0



Did you tried:



http://www.jasperforge.org/jaspersoft/opensource/business_intelligence/irepo
rt/screencast3.html



Regards.



_____

De: Enock Mangunda [mailto:***@ebiz.co.zw]
Enviado el: Viernes, 07 de Marzo de 2008 08:24 a.m.
Para: ***@netbeans.org
Asunto: [nbusers] Using Netbeans and JasperReports



Hie,

I am failing to get my application to view JasperReports reports. I am quite
lost so can someone send me a simple project that clearly shows how to
incorporate JasperReports into a Java project. I have gone thruogh the
JasperReports tutorial but have had no success.



Nyaradzo Enock Mangunda

Comprint Support Team

EBI Zimbabwe (Pvt) Limited
Giulio Toffoli
2008-03-07 17:10:29 UTC
Permalink
Hi Enock,

After designing and previewing the report you should see a jasper file
in the same directory of your template file (.jrxml).

This file is the compiled version of your report and it is what you
usually ship with your application.

Depending of what kind of application is (web or desktop application)
you need to integrate JasperReports in it.
The JasperReports package comes with a lot of sample. You can download
it from:

http://www.jasperforge.org/jasperreports/


Each report sample has a java class that shows how to run it.
The simplest code to execute a report is this one. It executes
test.jasper using an empty data source and put the result
in a pdf file.


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 = "/devel/examples/test.jasper";
String outFileName = "/devel/examples/test.pdf";
HashMap hm = new HashMap();
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);
}
}
}

This code is a sample of how to use a JDBC connection and preview the
result in the JasperViewer window:

import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.export.*;
import net.sf.jasperreports.view.JasperViewer;
import java.util.*;

public class JasperTest
{

private java.sql.Connection getConnection()
{
... put your code to get the connection here ...
}


public static void main(String[] args)
{
String fileName = "/devel/examples/test.jasper";

HashMap hm = new HashMap();
try
{
JasperPrint print = JasperFillManager.fillReport(fileName,
hm, getConnection() );
JasperViewer jasperViewer = new JasperViewer(print,false);
jasperViewer.setVisible(true);

}
catch (JRException e)
{
e.printStackTrace();
System.exit(1);
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
}
}
}


hope this can help.

Giulio
Post by Sergio Samayoa
Are you using iReport for NB?
http://www.jasperforge.org/jaspersoft/opensource/business_intelligence/ireport/page.php?name=nb-0.9.0
http://www.jasperforge.org/jaspersoft/opensource/business_intelligence/ireport/screencast3.html
Regards.
------------------------------------------------------------------------
*Enviado el:* Viernes, 07 de Marzo de 2008 08:24 a.m.
*Asunto:* [nbusers] Using Netbeans and JasperReports
Hie,
I am failing to get my application to view JasperReports reports. I am
quite lost so can someone send me a simple project that clearly shows
how to incorporate JasperReports into a Java project. I have gone
thruogh the JasperReports tutorial but have had no success.
_Nyaradzo Enock Mangunda_
*Comprint Support Team*
*EBI Zimbabwe (Pvt) Limited*
Giulio Toffoli
2008-03-07 17:25:03 UTC
Permalink
Another detail I forget to mention is that you'll need to add the jars
of JasperReports to your java project.
You will find all the required jars in the JasperReports package.
The most important jars are:

Required:
dist/jasperreports-x.y.z.jar
lib/commons-beanutils-1.7.jar
lib/commons-collections-2.1.jar
lib/commons-digester-1.7.jar
lib/commons-javaflow-20060411.jar
lib/commons-logging-1.0.2.jar
lib/commons-logging-api-1.0.2.jar
lib/png-encoder-1.5.jar
lib/jdt-compiler-3.1.1.jar

lib/itext-1.3.1.jar <-- Only if you plan to export you reports in PDF
lib/jxl-2.6.jar <-- Only if you plan to export your reports in XLS
lib/poi-3.0.1-FINAL-20070705.jar <-- Only if you plan to export your
reports in XLS
lib/jfreechart-1.0.0.jar <-- Only if you use the charts
lib/jcommon-1.0.0.jar <-- Only if you use the charts

If you use Groovy as report language
lib/groovy-all-1.0.jar

If you use the BeanShell compiler in your app (I don't thing you do)
lib/bsh-2.0b4.jar

If you use Hibernate and HQL
lib/antlr-2.7.5.jar
lib/hibernate3.jar

If you use and HSQL database
lib/hsqldb-1.7.1.jar

If you use Mondrian
lib/mondrian-2.3.2.8944.jar

if you use the XML DataSource (and XPath)
lib/xalan.jar
lib/xercesImpl.jar
lib/xml-apis.jar


I'm not sure how are used those ones (or what are the dependencies of
the other jars respect to these ones):
lib/jaxen-1.1.1.jar
lib/jpa.jar
lib/jakarta-bcel-20050813.jar
lib/saaj-api-1.3.jar
lib/servlet.jar


Since these jars are actually shipped with iReport too, from the next
version of the plugin available at the end of March
(but this is actually already implemented and available from the ireport
SVN repository) when you install the plugin ireport
will create a NetBeans library called JasperReports to easily add the
required jars to a java project.

Regards

Giulio
vps
2008-06-06 04:54:50 UTC
Permalink
Im using netBeans 5.5 and IReport 2.0.5. When I compile a java class, for eg:
JasperTest.java. Im getting the following errors:

C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:1: package
net.sf.jasperreports.engine does not exist
import net.sf.jasperreports.engine.*;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:2: package
net.sf.jasperreports.engine.export does not exist
import net.sf.jasperreports.engine.export.*;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:2: package
net.sf.jasperreports.view does not exist
import net.sf.jasperreports.view.JasperViewer;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:3: package
net.sf.jasperreports.engine.xml does not exist
import net.sf.jasperreports.engine.xml.JRXmlLoader;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:4: package
net.sf.jasperreports.engine does not exist
import net.sf.jasperreports.engine.JasperCompileManager;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:5: package
net.sf.jasperreports.engine does not exist
import net.sf.jasperreports.engine.JasperFillManager;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:6: package
net.sf.jasperreports.engine does not exist
import net.sf.jasperreports.engine.JasperPrint;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:7: package
net.sf.jasperreports.engine.design does not exist
import net.sf.jasperreports.engine.design.JasperDesign;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:8: package
net.sf.jasperreports.engine does not exist
import net.sf.jasperreports.engine.JasperReport;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:14: cannot
find symbol
symbol : class JasperPrint
location: class JasperTest
JasperPrint print = JasperFillManager.fillReport(fileName, hm,
new JREmptyDataSource());
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:14: cannot
find symbol
symbol : class JREmptyDataSource
location: class JasperTest
JasperPrint print = JasperFillManager.fillReport(fileName, hm,
new JREmptyDataSource());
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:14: cannot
find symbol
symbol : variable JasperFillManager
location: class JasperTest
JasperPrint print = JasperFillManager.fillReport(fileName, hm,
new JREmptyDataSource());
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:15: cannot
find symbol
symbol : class JRExporter
location: class JasperTest
JRExporter exporter = new
net.sf.jasperreports.engine.export.JRPdfExporter();
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:15: package
net.sf.jasperreports.engine.export does not exist
JRExporter exporter = new
net.sf.jasperreports.engine.export.JRPdfExporter();
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:16: cannot
find symbol
symbol : variable JRExporterParameter
location: class JasperTest
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,
outFileName);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:17: cannot
find symbol
symbol : variable JRExporterParameter
location: class JasperTest
exporter.setParameter(JRExporterParameter.JASPER_PRINT,print);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:21: cannot
find symbol
symbol : class JRException
location: class JasperTest
catch (JRException e)
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:64: cannot
find symbol
symbol : class JasperDesign
location: class ReportDriver
JasperDesign jasperDesign = JRXmlLoader.load(reportFile);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:64: cannot
find symbol
symbol : variable JRXmlLoader
location: class ReportDriver
JasperDesign jasperDesign = JRXmlLoader.load(reportFile);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:65: cannot
find symbol
symbol : class JasperReport
location: class ReportDriver
JasperReport jasperReport =
JasperCompileManager.compileReport(jasperDesign);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:65: cannot
find symbol
symbol : variable JasperCompileManager
location: class ReportDriver
JasperReport jasperReport =
JasperCompileManager.compileReport(jasperDesign);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:67: cannot
find symbol
symbol : class JasperPrint
location: class ReportDriver
JasperPrint jasperPrint =
JasperFillManager.fillReport(jasperReport, null, jdbcConnection);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:67: cannot
find symbol
symbol : variable JasperFillManager
location: class ReportDriver
JasperPrint jasperPrint =
JasperFillManager.fillReport(jasperReport, null, jdbcConnection);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:68: cannot
find symbol
symbol : variable JasperViewer
location: class ReportDriver
JasperViewer.viewReport(jasperPrint);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\org\json\JSONObject.java:282:
warning: non-varargs call of varargs method with inexact argument type for
last parameter;
cast to java.lang.Object for a varargs call
cast to java.lang.Object[] for a non-varargs call and to suppress this
warning
this.put(key, method.invoke(bean, null));
Note:
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\user\servl\UserDeleteServl.java
uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
24 errors
1 warning


I have added the following jar file using Library Manager:

jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/commons-beanutils-1.7.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/commons-collections-2.1.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/commons-digester-1.7.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/commons-javaflow-20060411.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/commons-logging-1.0.2.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/iReport.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/itext-1.3.1.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/jasperreports-2.0.5.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/xercesImpl.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/png-encoder-1.5.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/jdt-compiler-3.1.1.jar!/


Hope anyone will help me.

Thanks n Regards,
VPS
--
View this message in context: http://www.nabble.com/Using-Netbeans-and-JasperReports-tp15897993p17684661.html
Sent from the Netbeans - Users mailing list archive at Nabble.com.
Gary Greenberg
2008-06-06 20:17:08 UTC
Permalink
I am using JasperReports actively, although not for long. I'll try to
help you if I can.
Unlike you I am using NB6.1 and iReports plugin is broken for it. So, I
am using individual iReports 3.0.0 installation to design my report
templates (jrxml files). I am also using JasperReports 3.0.0 to compile
an run my projects.

You should not be getting most of these errors if jasperreports.jar is
in your compile classpath.
Check if it is. Also check if the file is not corrupted, i.e. open the
jar file and see if needed classes are there.
Personally, I would recommend to download v.3.0.0. from
http://sourceforge.net/project/showfiles.php?group_id=36382&package_id=2
8579&release_id=600358 and build a library from there. Be aware that you
need not just jasperreports.jar but the whole project. I don't know how
it was done in NB5.5 but I found out that iReport plugin does not add
anything to the build.xml file to compile .jrxml files into .jasper
files. So, I overwrite the ant task as below.
<target name="-post-compile">
<taskdef name="jrc"
classname="net.sf.jasperreports.ant.JRAntCompileTask" >
<classpath>
<pathelement location="${jasper.path}"/>
<fileset dir="${jasper.lib.dir}">
<include name="**/*.jar"/>
</fileset>
</classpath>
</taskdef>
<mkdir dir="${build.classes.dir}/jasper"/>
<jrc destdir="${build.classes.dir}/jasper">
<src>
<fileset dir="${src.java.dir}">
<include name="**/*.jrxml"/>
</fileset>
</src>
</jrc>
</target>

Where
jasper.path=${jasper.root}${file.separator}dist${file.separator}jasperre
ports-3.0.0.jar
jasper.lib.dir=${jasper.root}${file.separator}lib

jasper.root is defined via environment variable and points to the
installation of the JasperReports project.

I hope it'll help. If not ask again.


-----Original Message-----
From: vps [mailto:***@arxaa.com]
Sent: Thursday, June 05, 2008 9:55 PM
To: ***@netbeans.org
Subject: [nbusers] Using Netbeans and JasperReports


Im using netBeans 5.5 and IReport 2.0.5. When I compile a java class,
for eg:
JasperTest.java. Im getting the following errors:

C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:1:
package
net.sf.jasperreports.engine does not exist
import net.sf.jasperreports.engine.*;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:2:
package
net.sf.jasperreports.engine.export does not exist
import net.sf.jasperreports.engine.export.*;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:2:
package
net.sf.jasperreports.view does not exist
import net.sf.jasperreports.view.JasperViewer;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:3:
package
net.sf.jasperreports.engine.xml does not exist
import net.sf.jasperreports.engine.xml.JRXmlLoader;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:4:
package
net.sf.jasperreports.engine does not exist
import net.sf.jasperreports.engine.JasperCompileManager;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:5:
package
net.sf.jasperreports.engine does not exist
import net.sf.jasperreports.engine.JasperFillManager;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:6:
package
net.sf.jasperreports.engine does not exist
import net.sf.jasperreports.engine.JasperPrint;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:7:
package
net.sf.jasperreports.engine.design does not exist
import net.sf.jasperreports.engine.design.JasperDesign;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:8:
package
net.sf.jasperreports.engine does not exist
import net.sf.jasperreports.engine.JasperReport;
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:14:
cannot
find symbol
symbol : class JasperPrint
location: class JasperTest
JasperPrint print = JasperFillManager.fillReport(fileName,
hm,
new JREmptyDataSource());
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:14:
cannot
find symbol
symbol : class JREmptyDataSource
location: class JasperTest
JasperPrint print = JasperFillManager.fillReport(fileName,
hm,
new JREmptyDataSource());
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:14:
cannot
find symbol
symbol : variable JasperFillManager
location: class JasperTest
JasperPrint print = JasperFillManager.fillReport(fileName,
hm,
new JREmptyDataSource());
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:15:
cannot
find symbol
symbol : class JRExporter
location: class JasperTest
JRExporter exporter = new
net.sf.jasperreports.engine.export.JRPdfExporter();
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:15:
package
net.sf.jasperreports.engine.export does not exist
JRExporter exporter = new
net.sf.jasperreports.engine.export.JRPdfExporter();
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:16:
cannot
find symbol
symbol : variable JRExporterParameter
location: class JasperTest
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,
outFileName);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:17:
cannot
find symbol
symbol : variable JRExporterParameter
location: class JasperTest

exporter.setParameter(JRExporterParameter.JASPER_PRINT,print);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\JasperTest.java:21:
cannot
find symbol
symbol : class JRException
location: class JasperTest
catch (JRException e)
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:64:
cannot
find symbol
symbol : class JasperDesign
location: class ReportDriver
JasperDesign jasperDesign = JRXmlLoader.load(reportFile);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:64:
cannot
find symbol
symbol : variable JRXmlLoader
location: class ReportDriver
JasperDesign jasperDesign = JRXmlLoader.load(reportFile);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:65:
cannot
find symbol
symbol : class JasperReport
location: class ReportDriver
JasperReport jasperReport =
JasperCompileManager.compileReport(jasperDesign);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:65:
cannot
find symbol
symbol : variable JasperCompileManager
location: class ReportDriver
JasperReport jasperReport =
JasperCompileManager.compileReport(jasperDesign);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:67:
cannot
find symbol
symbol : class JasperPrint
location: class ReportDriver
JasperPrint jasperPrint =
JasperFillManager.fillReport(jasperReport, null, jdbcConnection);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:67:
cannot
find symbol
symbol : variable JasperFillManager
location: class ReportDriver
JasperPrint jasperPrint =
JasperFillManager.fillReport(jasperReport, null, jdbcConnection);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\ReportDriver.java:68:
cannot
find symbol
symbol : variable JasperViewer
location: class ReportDriver
JasperViewer.viewReport(jasperPrint);
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\org\json\JSONObject.java:282:
warning: non-varargs call of varargs method with inexact argument type
for
last parameter;
cast to java.lang.Object for a varargs call
cast to java.lang.Object[] for a non-varargs call and to suppress this
warning
this.put(key, method.invoke(bean, null));
Note:
C:\Users\VIshmy\Desktop\ARMS_XLS\src\java\arms\user\servl\UserDeleteServ
l.java
uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
24 errors
1 warning


I have added the following jar file using Library Manager:

jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/
commons-beanutils-1.7.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/
commons-collections-2.1.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/
commons-digester-1.7.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/
commons-javaflow-20060411.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/
commons-logging-1.0.2.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/
iReport.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/
itext-1.3.1.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/
jasperreports-2.0.5.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/
xercesImpl.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/
png-encoder-1.5.jar!/
jar:file:/C:/Users/VIshmy/Desktop/vismi/iReport-2.0.5/iReport-2.0.5/lib/
jdt-compiler-3.1.1.jar!/


Hope anyone will help me.

Thanks n Regards,
VPS
--
View this message in context:
http://www.nabble.com/Using-Netbeans-and-JasperReports-tp15897993p176846
61.html
Sent from the Netbeans - Users mailing list archive at Nabble.com.
Ben-Hur
2008-07-01 06:38:27 UTC
Permalink
Post by Giulio Toffoli
This code is a sample of how to use a JDBC connection and preview the
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.export.*;
import net.sf.jasperreports.view.JasperViewer;
import java.util.*;
public class JasperTest
{
private java.sql.Connection getConnection()
{
... put your code to get the connection here ...
}
public static void main(String[] args)
{
String fileName = "/devel/examples/test.jasper";
HashMap hm = new HashMap();
try
{
JasperPrint print = JasperFillManager.fillReport(fileName,
hm, getConnection() );
JasperViewer jasperViewer = new JasperViewer(print,false);
jasperViewer.setVisible(true);
}
catch (JRException e)
{
e.printStackTrace();
System.exit(1);
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
}
}
}
hope this can help.
Giulio
Hi guys! I'm new at Java and I want to ask, what codes do I need to put in
the section where you said to " ... put your code to get the connection here
...". Can you give a sample code so I can try and modify it myself. I'm
using a MySQL database by the way. Thanks in advance! --Ben
--
View this message in context: http://www.nabble.com/Using-Netbeans-and-JasperReports-tp15897993p18210178.html
Sent from the Netbeans - Users mailing list archive at Nabble.com.
Ben-Hur
2008-07-02 13:59:03 UTC
Permalink
Hello again! Ok, so now I am able to successfully compile and run the
application. But when I click the button, it shows a
"java.lang.ClassNotFoundException: com.mysql.jdbc.Driver" error. So I
searched the net and found a post saying that I should paste the
mysql-connector.jar in the

jdk/jre/lib
and
jdk/jre/lib/ext

folders. I did that and restarted Netbeans. When I run it again. A new error
shows, it is the "java.lang.NullPointerException" error. What do I do now?

Thanks again!
--
View this message in context: http://www.nabble.com/Using-Netbeans-and-JasperReports-tp15897993p18238106.html
Sent from the Netbeans - Users mailing list archive at Nabble.com.
Loading...