Create Java archive of report templates and dependencies

What are the steps to create a distribution library that contains all the:

  • Report images
  • Internationalized resource bundles
  • Class files (for custom functionality)
  • Report templates


thangalin's picture
Joined: Apr 21 2008 - 4:34am
Last seen: 3 years 3 months ago

2 Answers:

This answer makes the following assumptions:

  • The class files and resource bundles are located in the "build" directory (should created by default when writing custom Java classes).
  • The distribution directory for the Java archive will be named "dist".
  • The images used by the reports are in an "images" directory and in SVG format.
  • The report templates have been compiled and are in the main project folder.


  1. In the project folder create a file named "build_dist.xml"
  2. Copy the following content into build_dist.xml:
<?xml version="1.0"?>
<project name="DistributionLibrary" default="dist" basedir=".">
  <description>Archives templates, bundles, class files.</description>
  <property name="build" location="build" />
  <property name="dist" location="dist" />
  <target name="dist" description="Build distribution archive.">
    <mkdir dir="${dist}" />
    <jar destfile="${dist}/templates.jar">
      <fileset dir="${build}" includes="**/*" />
      <fileset dir="." includes="images/*.svg" />
      <fileset dir="." includes="**/*.jasper"/>
  1. Right-click on the project name.
  2. Select Properties.
  3. Select Builders.
  4. Click New.
  5. Select Ant Builder.
  6. Click OK to display the Edit Configuration dialog.
  7. Set Buildfile to: ${project_loc}/build_dist.xml
  8. Set Base Directory to: ${project_loc}
  9. Click the Targets tab.
  10. Click Set Targets beside "After a 'Clean'".
  11. Uncheck dist, if it is checked.
  12. Click OK.
  13. Click Set Targets beside "Manual Build".
  14. Check dist, if it is unchecked.
  15. Click OK.
  16. Click OK to close the Edit Configuration dialog.
  17. Click OK to close the Project properties dialog.

The archive is now bulit automatically after each successful project build. Try it as follows:

  1. Select Project >> Clean.
  2. Click OK.

In the Console panel you should see BUILD SUCCESSFUL.

Once the build is successful, the dist directory will contain a file called templates.jar that contains an archive that can be used as a resource for reports (in a Java application).

thangalin's picture
Joined: Apr 21 2008 - 4:34am
Last seen: 3 years 3 months ago
From "Project Explorer", just right click on the project (usually the top element in the tree" and select "export" - "General" - "Archive File".
hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 9 months ago