Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I compile jrxml to get jasper?

I have jrxml file, I want to compile this to get .jasper. How do I compile and get that jasper file?

like image 271
Mohamed Saligh Avatar asked Dec 16 '10 01:12

Mohamed Saligh


People also ask

How do I create a Jasper file?

In Jaspersoft Studio select the menu item Project->Build Automatically. Now Studio will create the . jasper file in the same location as the . jrxml file.

How do I compile JasperReports?

jrxml report are in MyReports group. Expand this group, find your . jrxml report and rightclick on it. In context menu choose 'Compile report'.

What is the difference between Jasper and Jrxml?

jrxml is a human readable XML file that contains the report template i.e. report structure and its formatting rules. . jasper is the compiled report template i.e. compiled . jrxml file.

How to compile a jrxml file to jjasper?

The JasperReports design file .jrxml will automatically be compiled to .jasper in same folder as .jrxml if no errors are present. <target name="compile" description="Compiles report designs specified using the 'srcdir' in the <jrc> tag."

How to compile JasperReports design file to Jaspersoft studio?

In IDE Jaspersoft Studio ( JSS) or the older version iReport Designer it is sufficient to press Preview. The JasperReports design file .jrxml will automatically be compiled to .jasper in same folder as .jrxml if no errors are present. <target name="compile" description="Compiles report designs specified using the 'srcdir' in the <jrc> tag."

How does JRXML work with JasperDesign?

During compilation of the jrxml file (using some JasperReports classes) the XML is parsed and loaded in a JasperDesign object, which is a rich data structure that allows you to represent the exact XML contents in memory.

How do I run a Jaspersoft report in Eclipse?

In eclipse, Install Jaspersoft Studio for eclipse. Right click the .jrxml file and select Open with JasperReports Book Editor. Open the Design tab for the .jrxml file. On top of the window you can see the Compile Report icon.


10 Answers

There are three ways to compile jrxml to jasper.

  1. You can do direct compile via compile button (hammer logo) on iReport designer.

  2. You can use ant to compile as shown in the Ant Compile Sample.

    <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>
    

    Below is the report compile task on my current project.

    alt text

    addition from Daniel Rikowski :

  3. You can also use the JasperCompileManager class to compile from your java code.

    JasperCompileManager.compileReportToFile(
                    "our_jasper_template.jrxml", // the path to the jrxml file to compile
                    "our_compiled_template.jasper"); // the path and name we want to save the compiled file to
    
like image 140
Sal Prima Avatar answered Oct 15 '22 11:10

Sal Prima


For anyone coming across this question who uses Jaspersoft Studio (which, I think, is replacing iReports; it's quite similar, still freeware, just based on eclipse), look for the "Compile Report" icon on top of the editor area of your .jrxml file. Its icon, first in that line of icons, is a file with binary numbers on it (at least in version 5.6.2):

Jaspersoft Studio - compile report

Clicking this icon will generate the .jasper file in the same directory as the .jrxml file.

like image 32
Amos M. Carpenter Avatar answered Oct 15 '22 10:10

Amos M. Carpenter


with maven it is automatic:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>jasperreports-maven-plugin</artifactId>
  <configuration>
    <outputDirectory>target/${project.artifactId}/WEB-INF/reports</outputDirectory>
  </configuration>
  <executions>
    <execution>
      <phase>prepare-package</phase>
      <inherited>false</inherited>
      <goals>
         <goal>compile-reports</goal>
      </goals>
    </execution>
  </executions>
  <dependencies>
    <dependency>
       <groupId>net.sf.jasperreports</groupId>
       <artifactId>jasperreports</artifactId>
       <version>3.7.6</version> 
    </dependency>
    <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
       <version>1.2.16</version>
       <type>jar</type>
     </dependency>
  </dependencies>
</plugin>
like image 42
leccionesonline Avatar answered Oct 15 '22 10:10

leccionesonline


I'm using iReport 2.0.2 to generate the jasper file.

I didn't found the hammer logo, but I have a menu create > compile in the menu bar who create the the jasper file in the iReport program files folder :

IReport Logs :"Compilation vers le fichier... .\SalesOrderItemsSubreportA4.jasper -> C:\Program Files\JasperSoft\iReport-2.0.2\SalesOrderItemsSubreportA4.java"

like image 27
Grégory Avatar answered Oct 15 '22 10:10

Grégory


Using iReport designer 5.6.0, if you wish to compile multiple jrxml files without previewing - go to Tools -> Massive Processing Tool. Select Elaboration Type as "Compile Files", select the folder where all your jrxml reports are stored, and compile them in a batch.

like image 44
Vivek Avatar answered Oct 15 '22 12:10

Vivek


In eclipse,

  • Install Jaspersoft Studio for eclipse.
  • Right click the .jrxml file and select Open with JasperReports Book Editor
  • Open the Design tab for the .jrxml file.
  • On top of the window you can see the Compile Report icon.
like image 29
Lucky Avatar answered Oct 15 '22 10:10

Lucky


If you are using iReport you can easily do it.

  1. When you click preview it will automatically compile.
  2. There is an option to make it complie. You can compile by selecting the page then right click you will get the compile option.
like image 38
Praveen P Moolekandathil Avatar answered Oct 15 '22 12:10

Praveen P Moolekandathil


Using Version 5.1.0:

Just click preview and it will create a YourReportName.jasper for you in the same working directory.

like image 45
Ali Avatar answered Oct 15 '22 12:10

Ali


  1. Open your .jrxml file in iReport Designer.
  2. Open the Report Inspector (Window -> Report Inspector).
  3. Right-click your report name on the top of the inspector and then click "Compile Report".

You can also Preview your report so it's automatically compiled.

like image 27
rickbala_ Avatar answered Oct 15 '22 10:10

rickbala_


if you are using the eclipse IDE you just do a right click in the .jrxml file and then click the compile option

like image 23
Natasha Avatar answered Oct 15 '22 12:10

Natasha