B4J Library jJasperReports Library

Hi. I want to share this jJasperReports library with the community.
It needs several libraries to work. I provided a link: download
---More libraries needed (missing from the first link): download
You also need to download databases jdbc drivers: sql jdts, mysql and oracle
New Link (All jar files are included in this link): Download
All jars need to be placed in Additional Libraries folder.
In the B4J project you need to add a jar file: #AdditionalJar: itext-2.1.7.js1
Library files and a small example is provided.
Please feel free to test the library.
Note: for some reason when using SubReports, the compiled (.jasper) files need to be in the same level as the app jar file. XML Reports (.jrxml) can be in any other folder different from the app jar file. (e.g. if report.jrxml is in File.DirApp & "/reports" then all compiled (.jasper) subreports need to be in File.DirApp. In the example provided .jrxml and .jasper are in the same level as jaspertest.jar.

v1.00 - Release
v1.10 - SQLite support added. MySQL useSSL variable added.
v1.12 - Changed the way the JasperViewer works. Now you can set the form to full screen, use the default size and location or set a specific size and location.
v1.13 - Added method PrintDirectlyToPrinter.
v1.20 - Access support added via uCanAccess jdbc driver. Note: When creating reports in Jaspersoft Studio you need to add all jar files that ucanaccess needs. The metadata won't work but you can create a query and it will work.
v1.22 - Added functions to export report to XLS and XLSX. Note: need 2 more jar files: download. Copy them into Additional Libraries folder.
v1.24 - Added function Print3 to be able to show reports without a Data Source.

------------------------------------------

NEW VERSION 2.00
Special thanks to Num3 for testing this library and helping me getting it done.

Instructions:
1. Libraries needed: Donwload
2. Place all jars in Additional Libraries folder
3. Specify in B4J project with #AdditionalJar: the database that is going to be used. (e.g. #AdditionalJar: mysql-connector-java-5.1.49-bin)
a. If using ucanaccess-5.1.0 database please add these in addition to #AdditionalJar: ucanaccess-5.0.1:
- #AdditionalJar: commons-lang3-3.8.1
- #AdditionalJar: commons-logging-1.2
- #AdditionalJar: hsqldb-2.5.0
- #AdditionalJar: jackcess-3.0.1

v2.00 - Same functionality as v1.24 but based on jasperreports-6.17.0. Previous v1.24 was based on jasperreports-6.7.1.
 

Attachments

  • mainform.png
    mainform.png
    8.1 KB · Views: 1,536
  • jrxml_exported_to_pdf.png
    jrxml_exported_to_pdf.png
    53.9 KB · Views: 1,520
  • jrxml_subreports.png
    jrxml_subreports.png
    53.6 KB · Views: 1,621
  • jrxml_single_report.png
    jrxml_single_report.png
    16.7 KB · Views: 1,542
  • jJasperReports.zip
    10.2 KB · Views: 849
  • sqlite_report.png
    sqlite_report.png
    35.1 KB · Views: 1,362
  • jaspertest.zip
    2.8 KB · Views: 897
  • jJasperReports - 1.24.zip
    17.4 KB · Views: 570
  • jJasperReports - 2.00.zip
    17.6 KB · Views: 450
Last edited:

amorosik

Expert
Licensed User
Using the jJasperReport 2.00 library I can't find a function to indicate as Firebird database
Using JasperSoft Studio 6.20.5 I can create the report and connect it correctly to the data, but then from B4J code I can't indicate the correct connection
Is there any other way to specifically point to Firebird or any odbc/jdbc data source?
 

Juan Marrero

Active Member
Licensed User
Longtime User
Using the jJasperReport 2.00 library I can't find a function to indicate as Firebird database
Using JasperSoft Studio 6.20.5 I can create the report and connect it correctly to the data, but then from B4J code I can't indicate the correct connection
Is there any other way to specifically point to Firebird or any odbc/jdbc data source?
For that I havento make changes to the library and possibly use the latest version of Jasper Jar file which will take some time and honestly I don't have that time for now.
 
Can you get the value of File.DirApp and check if that is the correct folder the jrxml should be? At first I got issues with report or subreport or image location in production mode. If I remember well subreport and images has to be at the same level as main report.
Hi Juan,
sorry for the delay in my reply.

I've tried moving the project folder to a shorter path (e.g. "C:\temp").
I've tried to log "File.DirApp" and it looks the same from both release mode and .jar, and i also tried moving the jrxml to an absolute path.
Nothing changes.
Report has no subreports or images.

I don't understand where the design XML file is compiled, is there any way to figure out where it is?

To work around this problem I tried to use this command:

B4X:
report=jasper.CompileXMLToFile2(design,File.DirApp & "/out")

but it doesn't work because it gives me this error: "cannot assign an empty value".

Do you have any idea about it?


Thanks a lot for your help,
Christian
 

amorosik

Expert
Licensed User
I have a report where, in the detail section
One db field is 'flag_congelato' a boolean db type
I would like an X to appear in the repot if the flag_congelato value is true (-1), or a null string if the flag_congelato value is false (0)
I used the formula
$F{flag_congelato}.equals(true) ? "X" : " "
inside a textbox on the report, but it doesn't work as expected in the sense that I don't see the X appear on any row, even if the flag_congelato value is true (-1)
What is the correct way to get the string 'X' if the value of the flag_congelato field is true?

(B4j 9.80, jdk 14.0.1, Jaspersoft Studio 6.20.5, jJasperReport 2.00)
 
Last edited:
Can you get the value of File.DirApp and check if that is the correct folder the jrxml should be? At first I got issues with report or subreport or image location in production mode. If I remember well subreport and images has to be at the same level as main report.
Hi Juan,
i tried different ways to compile the .jrxml but always with the same result.
If I load a .jasper file it returns no errors, but any other variant doesn't work.
Do "compileXML" commands create a temporary file? And if so, where?
Is it possible there are missing libraries? Or other types of dependencies?
The alternative would be to modify from external the query in the .jrxml file, compile the .jasper file again from external and finally print the report from b4j.
Even though it's harder this way, by now I would like to understand what is not working now just out of curiosity. šŸ˜“

Sorry to bother you again.

Thanks,
Christian
 

Juan Marrero

Active Member
Licensed User
Longtime User
Hi Juan,
sorry for the delay in my reply.

I've tried moving the project folder to a shorter path (e.g. "C:\temp").
I've tried to log "File.DirApp" and it looks the same from both release mode and .jar, and i also tried moving the jrxml to an absolute path.
Nothing changes.
Report has no subreports or images.

I don't understand where the design XML file is compiled, is there any way to figure out where it is?

To work around this problem I tried to use this command:

B4X:
report=jasper.CompileXMLToFile2(design,File.DirApp & "/out")

but it doesn't work because it gives me this error: "cannot assign an empty value".

Do you have any idea about it?


Thanks a lot for your help,
Christian
I'm on vacation like 5000 miles from home. I return home on July. Then I can check the error.
 

Juan Marrero

Active Member
Licensed User
Longtime User
I have a report where, in the detail section
One db field is 'flag_congelato' a boolean db type
I would like an X to appear in the repot if the flag_congelato value is true (-1), or a null string if the flag_congelato value is false (0)
I used the formula
$F{flag_congelato}.equals(true) ? "X" : " "
inside a textbox on the report, but it doesn't work as expected in the sense that I don't see the X appear on any row, even if the flag_congelato value is true (-1)
What is the correct way to get the string 'X' if the value of the flag_congelato field is true?

(B4j 9.80, jdk 14.0.1, Jaspersoft Studio 6.20.5, jJasperReport 2.00)
That is a jasper reports issue, not an issue with my library. And I know hoy to do this in Crystal Reports. Never donde this in Jasper Reports. Gonna have to wait till July when I get home to check it.
 
I'm on vacation like 5000 miles from home. I return home on July. Then I can check the error.
Hi Juan, no problem.

I probably found the error: if the .jar is run from a pc with only the jdk package installed and not the jre, the application works correctly.
If the jre package is also installed, however, it stops working.

I don't know if this will help you, at the moment I fixed it by uninstalling the jre package.

Anyway, have a good holiday!

Christian
 

Juan Marrero

Active Member
Licensed User
Longtime User
Hi Juan, no problem.

I probably found the error: if the .jar is run from a pc with only the jdk package installed and not the jre, the application works correctly.
If the jre package is also installed, however, it stops working.

I don't know if this will help you, at the moment I fixed it by uninstalling the jre package.

Anyway, have a good holiday!

Christian
That piece of information is very useful.
 

syerif

Active Member
Licensed User
Longtime User
Hi,

Thank you for great library, but i get problem while make exe project with packager, any suggestion step to do it

best regrads
 
Top