SomeJavaFileThatUsesJdom.java:14: cannot find symbol
symbol : constructor XMLOutputter(java.lang.String,boolean)
location: class org.jdom.output.XMLOutputter
private XMLOutputter xout = new XMLOutputter(" ", true);
The cause of the error is that the JDOM jar you are using is new and does not support this constructor. This really sucks because you'd think the newer version of some Java library should be backwards compatible. Anyway you just need to find the version that supports XMLOutputter constructor that accepts a String as the first argument and a Boolean as the second argument.
I'll walk through the steps to do this but if you just want to know which JDOM jar solves this issue then scroll down to find it.
To find the version of JDOM classes that fixes the error, you go to JDOM's archive binary page at http://www.jdom.org/dist/binary/archive/ and download and try each version during compilation. At the time of writing here's a list of available jars:
jdom-1.0.tar.gz
jdom-1.1.tar.gz
jdom-b3.tar.gz
jdom-b6.tar.gz
jdom-b7.tar.gz
jdom-b8.tar.gz
jdom-b9.tar.gz
jdom-b10.tar.gz
Download each one and untar or unzip it and identify the jar location. In older versions it should be named jdom-
javac -cp c:\jdom\jdom-b3.jar SomeJavaFileThatUsesJdom.java
And see if you are still getting the same error.
To save you trouble, I tried them all and found that jdom-b6.jar fixes the issue as the following execution trace suggests.
admin@one-minute-info$ javac -cp jdom-b6.jar SomeJavaFileThatUsesJdom.java
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
admin@one-minute-info$
As an alternative, you can modify your code to use the version of the jar you are using but it's highly NOT recommended. You'd end up having to debug issues resulted from the differences between the two versions of the jar. If you are feeling adventurous and love living on the edge knock yourself out!
Related Articles
Fixing Java No Class Def Found Error and Class Not Found Exception in MINUTES!
How Does Java Know Where to Find Core Libraries?
Eclipse: How to Make a Project a Java Project?
Fixing Java No Class Def Found Error and Class Not Found Exception in MINUTES!
How Does Java Know Where to Find Core Libraries?
Eclipse: How to Make a Project a Java Project?
Questions? Let me know!