my dog learned polymorphism*
The moose likes Other Java Products and Servers and the fly likes Creating the crystal reports from Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "Creating the crystal reports from Java" Watch "Creating the crystal reports from Java" New topic
Author

Creating the crystal reports from Java

paramesh ande
Greenhorn

Joined: Dec 15, 2005
Posts: 18
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

Joined: Aug 16, 2005
Posts: 14074
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Evgeniy Bulanov
Greenhorn

Joined: Dec 19, 2005
Posts: 23
Jesper de Jong, do you use jasperreports in big project? does it (jasperreport) really good?


Computers are like air conditioners - They stop working properly when you open Windows
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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

Joined: Jul 08, 2003
Posts: 24183
    
  34

Not an advanced Java topic. Moving to "Other Java Products and Servers."


[Jess in Action][AskingGoodQuestions]
paramesh ande
Greenhorn

Joined: Dec 15, 2005
Posts: 18
Hi JeaK Bleph,
Did u work on the crystal reports with java.Could u plz help me.
thanks®ards
paramesh
Eddie Lee
Greenhorn

Joined: Apr 27, 2005
Posts: 20
I too would like to know how to create specifically Crystal Reports with Java.

Thanks
Sudharshan Reddy Ch
Ranch Hand

Joined: Jul 12, 2006
Posts: 36
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


Cheers,
Sudha C Reddi
http://techelp.in
 
Consider Paul's rocket mass heater.
 
subject: Creating the crystal reports from Java
 
Similar Threads
generating crystal reports from struts
Crystal Reports using java servlets.
Does Crystal reports Works in Linux,Unix
Crystal Reports Integration with JSF
Java Accessing Crystal Reports