使用静态方法在 iReport 中获得 "Cannot be resolved to a type" 表达式

Got "Cannot be resolved to a type" in iReport for expression with static method

我创建了一个 Java 程序并在程序中为该程序创建了 jar 文件 class 名称是 DateFormate 静态方法是 demo()

然后将该 jar 文件添加到 iReport 文件,然后我将 static 方法称为

new com.it.DateFormate.demo()

然后出现此错误:

com.it.DateFormate cannot be resolved to a type

如果它是静态方法,调用将是

com.it.DateFormate.demo()

因此,没有new

要让它工作,class 需要在 classpath 中,如果你喜欢它在你的 IDE 中工作,请确保添加一个 jar(到 IDE) 包含此 class.