Examples of writing JasperReports using the Java API without JasperSoft Studio


JasperSoft Studio is proving to be an obstacle to getting started with JasperReports.  It freezes and I have to wait for it to come back (Ubuntu Linux).  I've spent hours trying to get a Table into the A4 template using a Collection of Java beans for a data source.  Chapter 14 in the documentation is nearly worthless for this.  I've finally gotten a Table in Studio that takes my Java class as a data source, but the columns are too narrow and apparently I can't resize them.  I edited the jrxml by hand and the Detail section in Studio would show a weird combination the Design and Source views overlayed onto each other.  I think I've finally gotten a Table in jrxml that will work, but it's taken far too long.  JasperSoft Studio isn't ready for prime time yet.

This is an example of creating a Table in JasperReports using jrxml and Java.  I don't know how he generated the jrxml, but he doesn't mention Studio.  Maybe he wrote the jrxml by hand or using some editor.  I'm open to using an editor to write jrxml if jrxml is indespensible, but trying to figure out Studio by reading the docs that have screen shots for contrived reports hasn't been successful.

This exercise with Studio reminds me of when I was starting in JavaFX.  The recommendation was to use SceneBuilder to create fxml files and combine them with Controllers to create JavaFX apps.  I found that approach clunky at best.  JavaFX veterans recommended that I stay with SceneBuilder, but I eventually ditched it.  I haven't used SceneBuilder or fxml in months, using the JavaFX API on its own to create entirely new apps and improve existing apps.  It's been a much better approach than futzing with SceneBuilder.

I would like to avoid Studio all together and just write reports with the JasperReports API, but I can't find examples of this.  If anyone could point me to JasperReports example code using only the Java API I would appreciate it.  If hand coding jrxml is the way to go I'm open to that too, but I hope there's a better jrxml editor than Studio.

dean.w.schulze's picture
Joined: Jul 10 2018 - 9:42am
Last seen: 1 year 11 months ago

In my question I meant jrxml, not frxml.

dean.w.schulze - 1 year 12 months ago

1 Answer:


For examples, look under "demo/samples" directory in JapserReports library. There's example codes on writing jrxml files.

BTW, the example in the link you provided was written using Jaspersoft Studio. Look at the second line.

><!-- Created with Jaspersoft Studio version 6.1.1.final using JasperReports Library version 6.1.1 --> <!-- 2015-11-25T00:02:30 -->

hozawa's picture
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 year 1 month ago