'Trouble Compiling Apache POI 5.2.2 Code - Factory.newInstance() methods

Apache POI newbie.

I am trying to use Apache POI 5.2.2 to generate footnotes in a Word document.

There are some useful SO posts on this topic:

However, when I try to run those examples, I get very consistent errors on these 3 Factory.newInstance() methods:

  • CTFtnEdn.Factory.newInstance();
  • CTStyle.Factory.newInstance();
  • CTDecimalNumber.Factory.newInstance();

The compiler says: "error: incompatible types: XmlObject cannot be converted to" either CTFtnEdn, CTStyle or CTDecimalNumber, as applicable.

Here is the full compilation error for one of these, but all 3 are similar:

Footnotes.java:68: error: incompatible types: XmlObject cannot be converted to CTFtnEdn CTFtnEdn ctfInstance = CTFtnEdn.Factory.newInstance();

poi-ooxml-full-5.2.2.jar is included in the compilation classpath.

I assume I have not included one or more jar files needed to get this working.

Any ideas how to get this working?



Solution 1:[1]

I believe I had conflicting jar files in the classpath. Removing one has fixed the issue. Axel Richter, thanks for helping me identify that.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user1821431