Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Can't Find Latest Java 1.6 Methods for XMLOutputFactory

Tags:

java

stax

I'm trying to use the newFactory() method for XMLOutputFactory, which was added in Java 6. But Eclipse keeps flagging newFactory() as undefined for the type XMLOutputFactory. JRE7 is the only runtime installed and in the build path of new Java projects. The project itself only has JRE7 (JRE System Library) and Ivy set up. The error I keep getting is

The method newFactory() is undefined for the type XMLOutputFactory

Any ideas how to get Eclipse to accept newFactory? Pretty much just using return XMLOutputFactory.newFactory() as the only place where the function is called.

like image 817
Shayon Saleh Avatar asked Aug 05 '13 22:08

Shayon Saleh


2 Answers

I had the same problem, and I fixed it by removing StAX from my classpath, because the version of XMLOutputFactory that comes with Java 7 provides the newFactory method, but the version of XMLOutputFactory that comes with StAX doesn't have it.

like image 114
davidwebster48 Avatar answered Oct 11 '22 23:10

davidwebster48


I had the same problem and it is resolved by using: XMLInputFactory factory = XMLInputFactory.newInstance(); you can visit:

click here for full description

like image 35
Superb Saif Avatar answered Oct 12 '22 01:10

Superb Saif