Jump to content
We've recently updated our Privacy Statement, available here ×

Need help getting started with scriptlets.


ktlam1955

Recommended Posts

Hello, I'm new to using scriptlets in iReport and I am having trouble getting started.  I am trying to write my first one. 

I selected "Use iReport internal scriptlet support" in Report Properties.

I used the Scriptlet editor in iReport to write a simple method just to start.

When I ran the report I got the following error.

Error compiling the Scriptlet Java source. net.sf.jasperreports.engine.JRException: Error compiling report java source files : C:\Program Files\GEBIT\TREND Analyst Community Edition\GEBIT_workspace\HDP reports\TSC Speed Station Data by CDS Route Number\JasperReports\Untitled_report_1Scriptlet.java 
    at net.sf.jasperreports.engine.design.JRJdk13Compiler.compileClasses(JRJdk13Compiler.java:119)
    at net.sf.jasperreports.engine.design.JRAbstractMultiClassCompiler.compileClass(JRAbstractMultiClassCompiler.java:45)
    at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:362)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.Main
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:179)
    at net.sf.jasperreports.engine.design.JRJdk13Compiler.compileClasses(JRJdk13Compiler.java:81)
    ... 3 more
Compilation running time: 94.

 

Can someone please tell me what I could be doing wrong?  Thanks in advance.

Code:



Post Edited by ktlam1955 at 05/29/2009 01:03



Post Edited by ktlam1955 at 05/29/2009 01:04
Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

First make sure that the tools.jar file from your JDK is in the lib folder of your jasper install.

When we create our own methods to call from a report we prefer to do the following instead of using jaspers internal scriptlet creator.

1. Either implement JRAbstractScriptlet or extend JRDefaultScriptlet.

http://jasperreports.sourceforge.net/api/index.html

2. To call it use

$P{REPORT_SCRIPTLET}.yourMethod(yourValue)

3. To point to your scriplet go to

Report Properties -> Scriplet Class -> Use This scriplet class

Put the package and class in the box

Link to comment
Share on other sites

Thank you for your help but I now have a different error.
It seems like I'm missing a library in my classpath but I don't know jar file I should get to get this library.

Errors compiling C:\Program Files\GEBIT\TREND Analyst Community Edition\GEBIT_workspace\HDP reports\TSC Speed Station Data by CDS Route Number\JasperReports\Untitled_report_1Scriptlet.java. C:\Program Files\GEBIT\TREND Analyst Community Edition\GEBIT_workspace\HDP reports\TSC Speed Station Data by CDS Route Number\JasperReports\Untitled_report_1Scriptlet.java:4: cannot access it.businesslogic.ireport.IReportScriptlet 
bad class file: C:\iReport\iReport-3.0.0\.\lib\iReport.jar(it/businesslogic/ireport/IReportScriptlet.class) 
class file has wrong version 49.0, should be 48.0 
Please remove or make sure it appears in the correct subdirectory of the classpath. 
public class Untitled_report_1Scriptlet extends it.businesslogic.ireport.IReportScriptlet { 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...