Your message has been sent.
This article has been saved to your account.
Go to my account
This article has been emailed to your Kindle.
Send this article
Complete the form below to send this article, iReport in NetBeans, to a friend (or to yourself). We will never share your details (or your friend's) with anyone. For more information, read our Privacy Policy.
NetBeans is a free, opensource Integrated Development Environment(IDE) for software developers. This IDE provides many good tools that are required to create professional, desktop, enterprise, web, and mobile applications using the Java language. We can also create reports in NetBeans, if the iReport plugin is installed. So far, we have created different types of reports with the iReport standalone version. In this article by Shamsuddin Ahammad, author of iReport 3.7, we will learn about:
- Installing the iReport plugins in NetBeans
- Creating different types of reports inside the NetBeans IDE
Creating different types of reports inside the NetBeans IDE
The first step is to download the NetBeans IDE and the iReport plugin for this. The iReport plugin for NetBeans is available for free download at the following locations: https://sourceforge.net/projects/ireport/files or http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=4425
After downloading the plugin, follow the listed steps to install the plugin in NetBeans:
- Start the NetBeans IDE.
- Go to Tools | Plugins.
- Select the Downloaded tab.
- Press Add Plugins….
- Select the plugin files. For iReport 3.7.0 the plugins are: iReport-3.7.0.nbm, jasperreports-components-plugin-3.7.0.nbm, jasperreportsextensions-plugin-3.7.0.nbm, and jasperserver-plugin-3.7.0.nbm. After opening the plugin files you will see the following screen:
- Check the Install checkbox of ireport-designer, and press the Install button at the bottom of the window. The following screen will appear:
- Press Next >, and accept the terms of the License Agreement.
- If the Verify Certificate dialog box appears, click Continue.
- Press Install, and wait for the installer to complete the installation.
- After the installation is done, press Finish and close the Plugins dialog. If the IDE requests for a restart, then do it. Now the IDE is ready for creating reports.







Creating reports
We have already learnt about creating various types of reports, such as reports without parameters, reports with parameters, reports with variables, subreports, crosstab reports, reports with charts and images, and so on. We have also attained knowledge associated with these types of reports. Now, we will learn quickly how to create these reports using NetBeans with the help of the installed iReport plugins.
Creating a NetBeans database JDBC connection
The first step is to create a database connection, which will be used by the report data sources. Follow the listed steps:
- Select the Services tab from the left side of the project window.
- Select Databases.
- Right-click on Databases, and press New Connection….
- In the New Database Connection dialog, set the following under Basic setting, and check the Remember password checkbox:

|
Option |
Value |
|
Driver Name |
MySQL (Connector/J Driver) |
|
Host |
localhost |
|
Port |
3306 |
|
Database |
inventory |
|
User Name |
root |
|
Password |
packt |

- Press OK. Now the connection is created, and you can see this under the Services | Databases section, as shown in the following screenshot:

Creating a report data source
The NetBeans database JDBC connection created previously will be used by a report data source that will be used by the report. Follow the listed steps to create the data source:
- From the NetBeans toolbar, press the Report Datasources button. You will see the following dialog box:
- Press New.
- Select NetBeans Database JDBC connection, and press Next >.
- Enter inventory in the Name field, and from the Connection drop-down list, select jdbc:mysql://localhost:3306/inventory [root on Default schema].
- Press Test, and if the connection is successful, press Save and close the Connections / Datasources dialog box.




Creating a simple report
We are going to create a report, which shows the list of products. Just follow the listed steps:
- Go to File | New File….
- Select Report from the Categories: section and Report Wizard from the File Types: section, as shown in the next screenshot:
- Press Next >. Select the Simple Blue layout and press Next > again.
- Enter ProductListNB.jrxml as File Name:, and Browse… to the reports folder.
- Press Next >.
- Select inventory from the Connections / Data Sources options.
- Write the following SQL command as the query:
SELECT ProductCode, Name, Description
FROM Product - Press Next >. You will see the following screen:
- Select all the fields, press >>, and then press Next >.
- Press Next > again without selecting any group.
- Press Finish. You will see the following output:
- Click on the Preview button to see the output, as shown in the following screenshot:
- You can design the report in the Designer section as per your design requirements.








Creating a parameterized report
We are going to create a report in NetBeans that shows the personal information of a particular customer. Follow the listed steps:
- Go to File | New File….
- Go to File | New File….
- Select Report from the Categories: section and Report Wizard from the File Types: section.
- Press Next > and select Simple Blue and press Next > again.
- Enter ParticularCustomerNB.jrxml as the File Name:.
- Browse… to the reports folder.
- Press Next >.
- Select inventory from the Connections / Data Sources drop-down list.
- Write the following SQL command as the query:
SELECT * FROM Customer
- Press Next >.

- Select all the fields, press >>, and then press Next >.>>
- Press Next > again without selecting any group.
- Press Finish. You will see the Designer view of the report.
- From the Report Inspector (see bottom left of the designer), select Parameters. Right-click on it, and click on Add Parameter.
- A parameter named parameter1 is added to the Parameters list. Select parameter1, and go to the parameter Properties window (see bottom-right of the designer).
- Change the Name to customerNo.
- Change the Parameter Class to java.lang.Integer.
- Check the Use as a prompt checkbox.
- Now, click on Report query (beside the Preview button), and replace the query with the following one:
SELECT * FROM Customer
WHERE CustomerNo = $P{customerNo} - Press OK and Preview the report. Input the customerNo, and see the output.



Summary
We have seen that creating iReport reports in NetBeans makes the process of developing and managing reports easier. We have got an initial idea of creating reports in NetBeans. In the same way, we can create the more complex reports (subreports, crosstab reports, reports with charts, and so on) as well.
If you have read this article you may be interested to view :
About the Author :
Shamsuddin Ahammad
Shamsuddin Ahammad is a Senior Lecturer and the Course Coordinator at Daffodil Institute of IT, Bangladesh. He has been teaching Java, Programming Methods, and Database Systems since 2002. He has experience in supervising hundreds of academic projects. Shamsuddin has a Masters degree in Management Information Systems (MIS) from Daffodil International University, Dhaka. He obtained the BSc(Hons) degree in Computing & Information Systems (CIS) of NCC Education Ltd, UK and London Metropolitan University joint programme from Daffodil Institute of IT. Before that, he completed the IDCS & IADCS of NCC Education Ltd. He is an Additional Reviewer of Conference on Quality Engineering in Software Technology (CONQUEST) organized by International Software Quality Institute (iSQI) in Germany. He is the author of book titled iReport 3.7 published from PACKT Publishing in March 2010.



Post new comment