Follow this Blog!

Aug 23, 2010

f Comment

Solving Java JDOM Jar Cannot Find Symbol Errors!

AmazonI am using the latest Java's JDOM library to compile some old code that uses JDOM, but I am getting "cannot find symbol" error. How do I solve it? Specifically the error I am getting looks like the following: 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 and download and try each version during compilation. At the time of writing here's a list of available jars:


Download each one and untar or unzip it and identify the jar location. In older versions it should be named jdom-.jar located in jdom/ folder. In newer versions it should be named jdom.jar located in jdom-/build/ folder. Use '-cp' argument option like the following when compiling the Java file to make javac use a specific jar (assuming the jar location is c:\jdom\jdom-b3.jar):

javac -cp c:\jdom\jdom-b3.jar
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
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.

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!

Questions? Let me know!
Please leave a comment here!
One Minute Information - by Michael Wen
Find Michael on Facebook
ADVERTISING WITH US - Direct your advertising requests to Michael