[英]getting java.lang.NoSuchMethodError
am using jacob jar for calling a macro of excel sheet from java code.. 我正在使用雅各布罐子从Java代码中调用Excel工作表的宏。
final ActiveXComponent excel = new ActiveXComponent("Excel.Application");
final Dispatch workbooks = excel.getProperty("Workbooks") .toDispatch();
final Dispatch workBook = Dispatch.call(workbooks, "Open", file.getAbsolutePath()).toDispatch();
com.jacob.com.Variant f = new com.jacob.com.Variant(true);
Dispatch.call(workBook, "Close", f);
and also am using maven to add all the jar dependency. 并且我正在使用maven添加所有jar依赖项。 but then i realised that i need to add the .DLL file then i added jacob jar manually and gave dll file in native library but now am getting 但是后来我意识到我需要添加.DLL文件,然后我手动添加了jacob jar并在本地库中提供了dll文件,但是现在
Exception in thread "main" java.lang.NoSuchMethodError: com.jacob.com.Dispatch.call(Lcom/jacob/com/Dispatch;Ljava/lang/String;Ljava/lang/Object;)Lcom/jacob/com/Variant;
at com.common.getData.callMacro(getData.java:650)
at com.testcases.PathAndAction.testScreen(PathAndAction.java:874)
at com.testcases.MainTestClass.testScreen(MainTestClass.java:54)
at com.testcases.MainTestClass.main(MainTestClass.java:15)
This could mean that at runtime, the version of the jar you're using with com.jacob.com.Dispatch
is different than the one com.common.getData
was compiled against. 这可能意味着,在运行时,你使用的jar的版本com.jacob.com.Dispatch
不同的是一个比com.common.getData
反对编译。 It's telling you that the class com.jacob.com.Dispatch
does exist but that it has no method named call
that takes Dispatch, String, Object
as arguments. 它告诉您com.jacob.com.Dispatch
类确实存在,但是它没有名为Dispatch, String, Object
作为参数的方法call
。
Are you perhaps compiling with one jar but running with another? 您是否正在使用一个jar进行编译,但又使用另一个jar运行?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.