Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Eclipse runnable JAR
steven.peeters
<p>Hi,</p>
<p> </p>
<p>I'm creating a standalone Java application that integrates BIRT Runtime in Eclipse with BIRT 4.5.0.</p>
<p> </p>
<p>Here is the code: (dumbed down version):</p>
<pre class="_prettyXprint _lang-">
import java.io.File;
import java.io.IOException;
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.IRenderTask;
import org.eclipse.birt.report.engine.api.IReportDocument;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunTask;
import org.eclipse.birt.report.engine.api.PDFRenderOption;
public class Convert {
private static EngineConfig config = null;
private static IReportEngine engine = null;
public static void main(String[] args) throws IOException, BirtException {
config = new EngineConfig();
config.setLogConfig("c:/temp/logs", java.util.logging.Level.ALL);
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine(config);
IReportRunnable report = null;
String rptDocumentFile;
report = engine.openReportDesign("c://temp//test.rptdesign");
IRunTask task = engine.createRunTask(report);
rptDocumentFile = "c://temp//test.rptdocument";
task.run(rptDocumentFile);
task.close();
IReportDocument rptdoc = engine.openReportDocument(rptDocumentFile);
IRenderTask rtask = engine.createRenderTask(rptdoc);
PDFRenderOption options = new PDFRenderOption( );
options.setOutputFormat("pdf");
options.setOutputFileName("c://temp//test.pdf");
rtask.setRenderOption( options );
rtask.render();
rptdoc.close();
rtask.close();
}
}
</pre>
<pre class="_prettyXprint">
</pre>
<p>Now, if I run this in Eclipse, everything runs fine.</p>
<p>When I export​ my project to a runnable JAR (Extract required libraries into generated JAR)​ , I get a nullpointer exception on "<i>engine</i> = factory.createReportEngine(<i>config</i>); "</p>
<p> </p>
<p>Note that exporting with the option "Copy required libraries into a sub-folder next to the generated JAR" does work.</p>
<p> </p>
<p>What am I doing wrong ​here?</p>
<p>​</p>
<p>Kind regards,</p>
<p> </p>
<p>Steven​</p>
<p> </p>
<p> </p>
Find more posts tagged with
Comments
AngryNerd
<p><a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/files/file/925-using-birt-430-with-maven/'>http://developer.actuate.com/community/forum/index.php?/files/file/925-using-birt-430-with-maven/</a></p>
;
<p> </p>
<p>I did see your post for few minutes. I think that will help u a lot.</p>
<p> </p>
<p>
</p>