Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Import JAR files (integrating JasperReports)

kojotDec 30 2010
Dear all,

I'm using JDeveloper 11.1.1.3.0 on Windows 7 32bit.

I search this forum and I google a lot, but I couldn't find any workable solution.

I downloaded the newest version of JasperReport and iReport from the official website. I've done some tutorials from this site and everything seems to work fine.

Now I want to integrate JDev with JasperReports. I create new Fusion Web Application ADF, I get the properties of Model project, Libraries and Classpath tab, add Library and click New... I set the Library name as JasperReports, location as Project, check Deploy ad Default. I add to Class path every JAR files in E:\JasperReports\jasperreports-3.7.6\lib and to Source path the whole directory E:\JasperReports\jasperreports-3.7.6\src. I get sure that the Export is checked and I save all the changes.

I create a new Java Class JasperTest and I use this sample 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();
        try {
            // Fill the report using an empty data source
            JasperPrint print = JasperFillManager.fillReport(fileName, hm, new JREmptyDataSource());
            
            // Create a PDF exporter
            JRExporter exporter = new JRPdfExporter();
            
            // Configure the exporter (set output file name and print object)
            exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, outFileName);
            exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
            
            // Export the PDF file
            exporter.exportReport();
            
        } catch (JRException e) {
            e.printStackTrace();
            System.exit(1);
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}
I cant compile this, it gives me Error(1,1): package net.sf.jasperreports.engine does not exist etc..
I cant import any class from JasperReports. Did I something wrong with importing the JAR files to my project ? Maybe I should set some system environment variable ? What else I can do ?

Any help will be appraciated.

Regards,
Wojtek.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 27 2011
Added on Dec 30 2010
0 comments
1,071 views