Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6930827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:29:54+00:00 2026-05-27T11:29:54+00:00

I’m trying to compile a jrxml using ant. I’ve created my jrxml on iReports

  • 0

I’m trying to compile a jrxml using ant.
I’ve created my jrxml on iReports so I dont have a build.xml.
When runing ant command, it asks for a build.xml.
I created this file in the same repertory as my jrxml but I dont know what I should put into it to link my jrxml to my scriptlet jar.
I’ll apreaciate your help, I’m a kind of lost..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:29:54+00:00Added an answer on May 27, 2026 at 11:29 am

    You can compile the report template with help of the net.sf.jasperreports.ant.JRAntCompileTask ant task.

    The sample taken from here:

    <path id="runClasspath">
        <pathelement location="${path_to_jasper_libs}"/>
        <pathelement path="${path_to_scriplet}\scriplet.jar"/>
    </path>
    
    <taskdef name="jrc" classname="net.sf.jasperreports.ant.JRAntCompileTask"> 
      <classpath refid="classpath"/>
    </taskdef>
    
    <target name="compile1"> 
      <mkdir dir="./build/reports"/> 
      <jrc 
        srcdir="./reports"
        destdir="./build/reports"
        tempdir="./build/reports"
        keepjava="true"
        xmlvalidation="true">
       <classpath refid="runClasspath"/>
       <include name="**/*.jrxml"/>
      </jrc>
    </target>
    
    <target name="compile2">
      <mkdir dir="./build/reports"/> 
      <jrc 
        destdir="./build/reports"
        tempdir="./build/reports"
        keepjava="true"
        xmlvalidation="true">
       <src>
        <fileset dir="./reports">
         <include name="**/*.jrxml"/>
        </fileset>
       </src>
       <classpath refid="runClasspath"/>
      </jrc> 
    </target> 
    

    The quote from the site:

    In addition to the srcdir and the destdir attributes, the jrc custom
    Ant task shipped with JasperReports supports the following attributes:

  2. compiler : Name of the class that implements the JRCompiler
    interface to be used for compiling the reports (optional).
  3. xmlvalidation : Flag to indicate whether the XML validation should be
    performed on the source report template files (true by default).
  4. tempdir : Location to store the temporarily generated files (the
    current working directory by default).
  5. keepjava : Flag to
    indicate if the temporary Java files generated on the fly should be
    kept and not deleted automatically (false by default).
  6. The working sample:

    The SampleJRScriptlet class:

    import com.google.common.base.Strings;
    import net.sf.jasperreports.engine.JRDefaultScriptlet;
    
    public class SampleJRScriptlet extends JRDefaultScriptlet {
    
        public String doubleField(String value) {
            return Strings.repeat(value, 2);
        }
    }
    

    The report template to compile (the report_with_scriplet.jrxml file):

    <jasperReport ... scriptletClass="SampleJRScriptlet">
        <property name="ireport.zoom" value="1.0"/>
        <property name="ireport.x" value="0"/>
        <property name="ireport.y" value="0"/>
        <queryString language="xPath">
            <![CDATA[/Northwind/Customers]]>
        </queryString>
        <field name="CustomerID" class="java.lang.String">
            <fieldDescription><![CDATA[CustomerID]]></fieldDescription>
        </field>
        <field name="CompanyName" class="java.lang.String">
            <fieldDescription><![CDATA[CompanyName]]></fieldDescription>
        </field>
        <field name="ContactName" class="java.lang.String">
            <fieldDescription><![CDATA[ContactName]]></fieldDescription>
        </field>
        <field name="ContactTitle" class="java.lang.String">
            <fieldDescription><![CDATA[ContactTitle]]></fieldDescription>
        </field>
        <detail>
            <band height="20" splitType="Stretch">
                <textField>
                    <reportElement x="0" y="0" width="100" height="20"/>
                    <textElement/>
                    <textFieldExpression><![CDATA[$P{REPORT_SCRIPTLET}.doubleField("$F{CustomerID}")]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="100" y="0" width="100" height="20"/>
                    <textElement/>
                    <textFieldExpression><![CDATA[$F{CompanyName}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="200" y="0" width="100" height="20"/>
                    <textElement/>
                    <textFieldExpression><![CDATA[$F{ContactName}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="300" y="0" width="100" height="20"/>
                    <textElement/>
                    <textFieldExpression><![CDATA[$F{ContactTitle}]]></textFieldExpression>
                </textField>
            </band>
        </detail>
    </jasperReport>
    

    My ant script (the compile_report.xml file):

    <project default="compile" basedir=".">
        <path id="classpath">
            <fileset dir="./../../target/alternateLocation">
                <include name="jasperreports-4.1.2.jar"/>
                <include name="commons-logging-1.0.2.jar"/>
                <include name="commons-digester-1.7.jar"/>
                <include name="commons-collections-2.1.jar"/>
                <include name="commons-beanutils-1.8.0.jar"/>
                <include name="groovy-all-1.0-jsr-05.jar"/>
            </fileset> 
        </path>
    
        <path id="runClasspath">
            <path refid="classpath"/> 
            <pathelement path="./../../target/myscriplet.jar"/>
        </path>
    
        <taskdef name="jrc" classname="net.sf.jasperreports.ant.JRAntCompileTask"> 
            <classpath refid="classpath"/>
        </taskdef>
    
        <target name="compile">
            <mkdir dir="./compiled_jasper"/> 
            <jrc 
        destdir="./compiled_jasper"
        tempdir="./compiled_jasper"
        keepjava="true"
        xmlvalidation="true">
                <src>
                    <fileset dir="./report">
                        <include name="**/*.jrxml"/>
                    </fileset>
                </src>
                <classpath refid="runClasspath"/>
            </jrc> 
        </target> 
    </project>
    

    The folder structure:

    report
      report_with_scriplet.jrxml
    compile_report.xml
    

    After the running sript folder structure will be:

    report
      report_with_scriplet.jrxml
    compiled_jasper
      report_with_scriplet_1323195663885_780040.groovy
      report_with_scriplet.jasper
    compile_report.xml
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.