use external JAR file in jaspersoft studio

2019-08-04 11:58发布

问题:

I have project in iReport,I want to build this in jasper studio,in that I use some external jar file to convert date,but in jasper studio I cant use them,I add those jar file in right click on project folder > properties > java build path > libraries > add External JARs..,iI get error when i want to see report preview :

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. com.ghasemkiani.util.icu.PersianDateFormat cannot be resolved to a type
                value = new com.ghasemkiani.util.icu.PersianDateFormat("yyyy/MM/dd").format(((java.sql.Timestamp)field_ORDERDATE.getValue())); //$JR_EXPR_ID=9$
                            <---------------------------------------->
2. com.ghasemkiani.util.icu.PersianDateFormat cannot be resolved to a type
                value = new com.ghasemkiani.util.icu.PersianDateFormat("yyyy/MM/dd").format(((java.sql.Timestamp)field_ORDERDATE.getOldValue())); //$JR_EXPR_ID=9$
                            <----------------------------------------> 

so,my question is : how can I add external jar file and use it?

回答1:

After you have added jar file to build path you have to restart your Jasper Studio.



回答2:

'In Jaspersoft Studio there is no longer a big unique classpath for the whole application like in iReport.

Each report is supposed to be part of a project. The project has a classpath, and here is where you should add the jars you need.

All is done by opening the projects view and right click the project folder with which you are working on. By default, new reports are created in the project "My Reports".'

Answer From JasperCommunity



回答3:

You have added the JAR file in the right location, but the issue (looking at the error message) is that the reference to the external class has not been provided.

Select the Field or Variable which needs to be run the new class (from JAR file). change the Class of the fields to your new class and run the report. You will have no errors then.



回答4:

In order to get the JRXML attached working what you will need to do is

Import the jar Tools(in the iReport Menu bar )-----> Options ----- > Click on Claspath Tab ------> ADD Jar -----> choose the JAr file (I Think You missed this step You need to import the JAR file through iReport through the above described process, no need of using IDE for classpath setting use iReport only)

It works for me.