iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library iReport Ultimate Guide - Nimsoft Library

13.07.2015 Views

iReport Ultimate GuideFigure 18-1Creation of a new project in NetBeans IDEThe best type of project is a Java Class Library; after all, we only have to write a simple class, not a real application.In the second step, give a name to the project (that is, the scriptlet) and choose a location for it (Figure 18-2).Figure 18-2Project detailsThe project is now created. The next step is to add to the project the JARs required to write your scriptlet. Technically, the onlyone required is jasperreports.jar, but you could add other JARs if required by your particular scriptlet. To do this in NetBeans,right-click the Libraries node in the Projects view, and select Add JAR/Folder (Figure 18-3).334

ScriptletsFigure 18-3Adding a Jar to the projectLocate the jasperreports JAR on your computer. If you have never downloaded a distribution of UR, you canfind a copy of this JAR in your iReport installation directory at this location:/ireport/modules/ext/jasperreports-x.y.z.jarNow that we have all the required classes in the project classpath, let’s move on to creating a package for the scriptlet andimplement it. Right-click the Source Packages node in Projects and select New > Java Class. The window to create the newclass pops up (Figure 18-4). In the sample I’ll set MyScriptlet as the class name and I’ll set the package name tocom.mycompany.Figure 18-4New Java class335

<strong>iReport</strong> <strong>Ultimate</strong> <strong>Guide</strong>Figure 18-1Creation of a new project in NetBeans IDEThe best type of project is a Java Class <strong>Library</strong>; after all, we only have to write a simple class, not a real application.In the second step, give a name to the project (that is, the scriptlet) and choose a location for it (Figure 18-2).Figure 18-2Project detailsThe project is now created. The next step is to add to the project the JARs required to write your scriptlet. Technically, the onlyone required is jasperreports.jar, but you could add other JARs if required by your particular scriptlet. To do this in NetBeans,right-click the Libraries node in the Projects view, and select Add JAR/Folder (Figure 18-3).334

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!