3
votes

Has anyone added the Birt Library to a project's build path successfully?

I installed Birt in Eclipse using Help-->Install New Software and copy paste the link for Birt 4.2.2 from the official website. Birt was downloaded from the internet and a new perspective appeared, namely Report Design. Apart from it no Library, no nothing. So I designed my report and started writing Java code in order to do a PDF export of my report, as I found on the internet. I wrote the following:

// Export Birt report
        String format = HTMLRenderOption.OUTPUT_FORMAT_PDF;
        EngineConfig config = new EngineConfig( );
        config.setEngineHome( "C:\\Tools\\Eclipse\\plugins\\org.eclipse.birt.report.viewer_4.2.2.v201302041142\\birt" );
        HTMLEmitterConfig hc = new HTMLEmitterConfig( );
        HTMLCompleteImageHandler imageHandler = new HTMLCompleteImageHandler( );
        hc.setImageHandler( imageHandler );
        config.setEmitterConfiguration( HTMLRenderOption.OUTPUT_FORMAT_HTML, hc );
        ReportEngine engine = new ReportEngine( config );
        IReportRunnable report = null;
        String reportFilepath = "C:/Workspace/reports/new_report.rptdesign";
        try {
            report = engine.openReportDesign( reportFilepath );
        }
        catch ( EngineException e ) {
            System.err.println( "Report " + reportFilepath + " not found!\n" );
            engine.destroy( );
            return;
        }
        IRunAndRenderTask task = engine.createRunAndRenderTask( report );
        HTMLRenderOption options = new HTMLRenderOption( );
        options.setOutputFormat( format );
        options.setOutputFileName( "C:/Workspace/reports/output.pdf" );
        task.setRenderOption( options );
        task.setParameterValues( parametersMap );
        try {
            task.run( );
        }
        catch ( EngineException e1 ) {
            System.err.println( "Report " + reportFilepath + " run failed.\n" );
            System.err.println( e1.toString( ) );
        }
        engine.destroy( );
        return;

Of course no Birt Library is set in my Build Path, so all Birt objects were red. I manually added all Birt jars that existed in Eclipse's plugins folder and all the reds disappeared. It seemed that everything was going great. When I run it I get:

java.lang.NoClassDefFoundError: org/eclipse/birt/report/engine/api/EngineException

while the org.eclipse.birt.report.engine.api package exists in my Build Path and the EngineException.class exist in the package. I am feeling that there are jar files that I am missing. I have searched for a solution in Birt home page and found nothing. Most tutorials have instructions regarding how to build a report. But nothing regarding how to get the library up and running with Java.

Is there a standard or automatic or official way to add Birt Library to Eclipse? It is made by Eclipse. It shouldn't be so difficult. Any help will be appreciated.

1

1 Answers

3
votes

Have you read this page -> http://wiki.eclipse.org/Servlet_Example_(BIRT)_2.1 Maybe you can find some hints there.