1. create your scriptlet and compile it, sample code is listed below.
package demo;
import java.math.BigDecimal;
import java.util.Date;
import net.sf.jasperreports.engine.JRDefaultScriptlet;public class scriptletFXTaxForm extends JRDefaultScriptlet {
CommonFunction cf;
public scriptletFXTaxForm(){
cf = new CommonFunction(true);
cf.ConnectToDB();
}
public BigDecimal Acca1(String sAcc){
BigDecimal dRet ;
dRet = BigDecimal.ZERO;return dRet;
}
public String methodName(){
return “scriptletFXTaxForm";
}
}
2. add you scriptlet to iReport classpath, don’t forget add all used lib or jar into iReport classpath ( if you lost one of them, you can’t work correctly )
3. In iReport , add demo.scriptletFXTaxForm to Scriptlet Class property.
in this demo case , your should add sqljdbc4.jar to iReport classpath
see also
http://blog.sacaluta.com/2007/07/jasperreports-scriptlet-example.html
http://blog.sacaluta.com/2005/10/using-jasperreports-scriptlet.html
Unfortunately, I still can’t use scriptlet in Netbeans plugin iReport.