• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating the crystal reports from Java

 
paramesh ande
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Could you please let me know how to generate the crystal reports or pdf reports from a java programm.What is the api required and how to use that ? plz let me know

Thanks in advance

paramesh
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15205
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know about Crystal Reports, but one free and open source library that's often used for creating reports in Java is JasperReports.
 
Evgeniy Bulanov
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong, do you use jasperreports in big project? does it (jasperreport) really good?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15205
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have never used it myself, but I've heard and read about it many times, it's a major reporting tool in the Java world. In fact, I was at JavaPolis (the biggest Java conference in Europe) last week and the guy who invented it, Teodor Danciu, held a talk there.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced Java topic. Moving to "Other Java Products and Servers."
 
paramesh ande
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi JeaK Bleph,
Did u work on the crystal reports with java.Could u plz help me.
thanks®ards
paramesh
 
Eddie Lee
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I too would like to know how to create specifically Crystal Reports with Java.

Thanks
 
Sudharshan Reddy Ch
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Follow these steps to access crystal reports using Java.


1. Create a WEB-INF\lib folder in the root of your Java *.class file
folder tree. For example:
com\
foobar\
WEB-INF\
lib\
2. Copy the following JAR files from �\Program Files\Common
Files\Business Objects\3.0\java\lib, ...\Program Files\Common
Files\Business Objects\3.0\java\lib\external, and ...\Program
Files\Common Files\Business
Objects\3.0\crystalreportviewers115\JavaViewer folders to the
WEB-INF\lib folder:

ReportViewer.jar

jrcerom.jar

Concurrent.jar

CrystalCharting.jar

CrystalCommon.jar

CrystalContentModels.jar

CrystalExporters.jar

CrystalExportingBase.jar

CrystalFormulas.jar

CrystalQueryEngine.jar

CrystalReportEngine.jar

CrystalReportingCommon.jar

icu4j.jar

keycodeDecoder.jar

log4j.jar

MetafileRenderer.jar

rasapp.jar

rascore.jar

rpoifs.jar

Serialization.jar

URIUtil.jar

xercesImpl.jar

xml-apis.jar
3. Add the above JAR files to your classpath and ensure that
ReportViewer.jar and jrcerom.jar are the first two JARs listed.
NOTE
If you are using Eclipse, you may have to quit Eclipse, edit your classpath file to move the
JARs to the beginning of the list, and then start Eclipse. Otherwise, you will receive a
"java.lang.IncompatibleClassChangeError: Implementing class" exception at run time.
4. Copy the CRConfig.xml file from your ...\Program Files\Common
Files\Business Objects\3.0\java folder to the root of your Java *.class
folder tree. For example:
CRConfig.xml
com\
foobar\
WEB-INF\
lib\
5. Edit the CRConfig.xml file's <reportlocation> tag to specify the
relative path to the folder containing the .rpt files. The path is
relative to the WEB-INF\lib folder. For example, if you specify ".",
then the .rpt file is loaded from the WEB-INF\lib folder.
<?xml version="1.0" encoding="utf-8"?>
<CrystalReportEngine-configuration>
<reportlocation>.</reportlocation>
6. Add code similar to the following to create the ReportViewerBean,
open the report, set the report on the viewer, and start the viewer:
import java.awt.*;
import javax.swing.*;
import com.crystaldecisions.ReportViewer.*;
// Use this for talking to JRC in-process
import com.crystaldecisions.reports.sdk.*;
import
com.crystaldecisions.sdk.occa.report.reportsource.*;
public class HelloWorldSwing
{
private static void createAndShowGUI()
{
try
{
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(false);
//Create and set up the window.
NOTE
If you are using Eclipse, you may have to quit Eclipse, edit your classpath file to move the
JARs to the beginning of the list, and then start Eclipse. Otherwise, you will receive a
"java.lang.IncompatibleClassChangeError: Implementing class" exception at run time.
4. Copy the CRConfig.xml file from your ...\Program Files\Common
Files\Business Objects\3.0\java folder to the root of your Java *.class
folder tree. For example:
CRConfig.xml
com\
foobar\
WEB-INF\
lib\
5. Edit the CRConfig.xml file's <reportlocation> tag to specify the
relative path to the folder containing the .rpt files. The path is
relative to the WEB-INF\lib folder. For example, if you specify ".",
then the .rpt file is loaded from the WEB-INF\lib folder.
<?xml version="1.0" encoding="utf-8"?>
<CrystalReportEngine-configuration>
<reportlocation>.</reportlocation>
6. Add code similar to the following to create the ReportViewerBean,
open the report, set the report on the viewer, and start the viewer:
import java.awt.*;
import javax.swing.*;
import com.crystaldecisions.ReportViewer.*;
// Use this for talking to JRC in-process
import com.crystaldecisions.reports.sdk.*;
import
com.crystaldecisions.sdk.occa.report.reportsource.*;
public class HelloWorldSwing
{
private static void createAndShowGUI()
{
try
{
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(false);
//Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
frame.setTitle("Testing 1, 2, 3");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ReportViewerBean viewer = new ReportViewerBean();
viewer.init(new String[0], null, null, null);
ReportClientDocument rpt =
new ReportClientDocument();
rpt.open("MyReport.rpt", 0);
IReportSource rptSource = rpt.getReportSource();
viewer.setReportSource(rptSource);
frame.getContentPane().add
(viewer, BorderLayout.CENTER);
frame.setSize(700, 500);
frame.setVisible(true);
viewer.start();
}
catch (Exception exception)
{
System.out.println(exception.toString());
}
}
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new
Runnable()
{
public void run()
{
createAndShowGUI();
}
});
}
}


i've followed all the steps given in spec, but i'm getting the following exception

com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: Unexpected error determining relative path---- Error code:-2147467259 Error code name:failed
at com.crystaldecisions.reports.reportengineinterface.a.a.b.a(Unknown Source)
at com.crystaldecisions.reports.sdk.ReportClientDocument.open(Unknown Source)
at pTravelImpressions.Channels.createAndShowGUI(Channels.java:51)
at pTravelImpressions.Channels$1.run(Channels.java:83)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:168)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:442)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:141)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:132)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:124)


Can anyone help me regarding.

ThanX
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic