views:

2258

answers:

4

Hi,

I'd like to start using iReport (netbeans edition) and replace the good old classic iReport 3.0.x. Seems like the classic iReport won't be improved anymore and abandoned at some point.

The point is that I need to start iReport from another java application. With iReport 3.0 it was pretty easy and straightforward: just invoke it.businesslogic.ireport.gui.MainFrame.main(args); and iReport is up and running.

The problem is I have no clue how to do the same thing in iReport-nb. The netbeans platform is a completely unkown for me and I could not find anything that looks like a main method or application starting point. It seems to load a lot of net beans platform stuff first and somehow hides the iReport starting point.

A: 

Why do you think it's abandoned? The latest version is 3.5.0 now btw. And what reasons are to change it to netbeans edition? Imho the main application is still iReport, and the NetBean plugin whis functionality is same with "plain old iReport".

And back to your question. iReport is stand-alone application, while "NetBeans edition" is just plugin, so you must start NetBeans IDE and then switch its layout to iReport plugin.

Vanger
m_pGladiator
The reasons to change is that I'd like to maintain up to date iReport version which covers the new functionality that comes with every JasperReports update. iReport 3.0 is ok by now. But at some point it will be too old. The new net beans iReport (from version 3.1.x and up to now 3.5.1) is rewritten from scratch and still lacks some features compared to 3.0 but this will be fixed soon.
m_pGladiator
+1  A: 

iReport based on the NetBeans platform works as standalone application (just like the classic one), even if it can be installed and used as NetBeans plugin too. Soon iR 3.5.2 will be released, it will cover all the remanining features present in iR classic that have been not covered yet in the previous versions, but on the other hand it provides plenty of new features and support for JasperReports 3.5.2 including a full new implementation of Barcode component, List (which are kind of light subreports), new chart types, support for multi-bands for detail and group header/footer, integrated preview and so on.

Here you can find some tips about how to start a NetBeans platform based applications from another java application. Not trivial, since you need to set up a little bit the environment, but definitively doable: http://wiki.netbeans.org/DevFaqPlatformAppAuthStrategies

Giulio

Thank you very much for the answer! I already downloaded 3.5.2 and it looks great! I'm going to take a look at the link ASAP.
m_pGladiator
Thanks once again! I managed to do it. I replaced the Installer class of the iReport module and implemented there the validate() method. This is the best place to add my startup code, because it is loaded by the module class loader, and not the framework class loader. More info can be found here: http://wiki.netbeans.org/DevFaqAppLifecycleHooks
m_pGladiator
A: 

1)Designing:For designing the report the idea is pretty much the same. After installing plugin make new->report and start designing.When you finish choose preview and the iReport will compile your report resulting a .jasper file.

2)Execute:Write the code to pass the data and run the .jasper from your java code Something like that:

JasperPrint print=null;
ResultSet rs=null;
try {
    Statement stmt = (Statement) myConnection.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE,//Default either way
            ResultSet.CONCUR_READ_ONLY);
    rs = stmt.executeQuery("select * from Table");
} catch (SQLException sQLException) {
}


    try {
        print = JasperFillManager.fillReport(filename, new HashMap(), new JRResultSetDataSource(rs));
    } catch (JRException ex) {                                                   
    }


try{
        JRExporter exporter=new net.sf.jasperreports.engine.export.JRPdfExporter();
        exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, pdfOutFileName);
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
        exporter.exportReport();

}..........

Argiropoulos Stavros
Sorry, -1, because this answer is not related to the question.
m_pGladiator
A: 

Hi m_pGladiator,

Could you give the detail? I meet the same problem with you, but I do not know how to implenment it.

Thanks

Ken
Actually I didn't manage to run it from another java application. I hacked the iReport, by replacing the installer class (see the comment to the accepted ansewer). I needed to run iReport from another application, just to be able to execute my startup code before the main method. This is achievable in netbeans by adding you code in the validate() method of the installer.class.
m_pGladiator