在jaspersoft studio中使用外部JAR文件

时间:2014-05-26 05:35:49

标签: java jasper-reports

我在iReport中有项目,我想在jasper工作室中构建它,因为我使用一些外部jar文件来转换日期,但在jasper工作室我无法使用它们,我在right click on project folder > properties > java build path > libraries > add External JARs..中添加了这些jar文件,当我想看报告预览时,我会收到错误:

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

所以,我的问题是:如何添加外部jar文件并使用它?

4 个答案:

答案 0 :(得分:4)

将jar文件添加到构建路径后,您必须重新启动Jasper Studio。

答案 1 :(得分:1)

'在Jaspersoft Studio中,整个应用程序不再像iReport那样有一个很大的独特类路径。

每份报告都应该是项目的一部分。该项目有一个类路径,您可以在这里添加所需的jar。

全部通过打开项目视图并右键单击您正在处理的项目文件夹来完成。默认情况下,在“我的报告”项目中创建新报告。'

来自JasperCommunity的回答

答案 2 :(得分:1)

您已将JAR文件添加到正确的位置,但问题(查看错误消息)是未提供对外部类的引用。

选择需要运行新类的字段或变量(来自JAR文件)。将字段的类更改为新类并运行报告。那你就没有错误了。

答案 3 :(得分:0)

为了使JRXML附加工作,您需要做的是

导入jar工具(在iReport菜单栏中)-----&gt;选项-----&gt;点击Claspath标签------&gt; ADD Jar -----&gt;选择JAr文件(我想你错过了这一步你需要通过上述过程通过iReport导入JAR文件,不需要使用IDE进行类路径设置只使用iReport)

它对我有用。

相关问题