javaclasspathjavacapache-commonsstringescapeutils

Javac not registering class path and methods correctly, symbol not found


I'm trying to use Apache Commons StringEscapeUtils. I've got this line of code in my import statement,

import org.apache.commons.lang3.StringEscapeUtils;

I've downloaded apache commons lang, extracted it and moved:

commons-lang3-3.4.jar

(Note: just the .jar file, not anything else that came with it. Not sure if it matters) into my lib directory where I store all of my other .jar files.

and I'm compiling it with:

javac -cp .:lib/* Main.java

However, javac is giving me this error:

./FactualResultDeserializer.java:43: error: cannot find symbol
                    factualObject.setTitle(unescapeHtml(unescapeJava(resultActivity.get(TITLE).getAsString())));
                                                        ^
  symbol:   method unescapeJava(String)
  location: class FactualResultDeserializer
./FactualResultDeserializer.java:51: error: cannot find symbol
                            categories[j] = unescapeHtml(unescapeJava(catArray.get(0).getAsJsonArray().get(j).getAsString()));
                                                         ^
  symbol:   method unescapeJava(String)
  location: class FactualResultDeserializer
2 errors

It did not give me an error for unescapeHtml which is from the same StringEscapeUtils package.

I have tried clearing the .class files to recompile. It did not solve the problem, help would be appreciated.

Thanks in advance!


Solution

  • Prefix the method calls with the name of the class to avoid any ambiguities. There is no unescapeHtml in org.apache.commons.lang3.StringEscapeUtils, use unescapeHtml3 or unescapeHtml4.

    factualObject.setTitle( 
       StringEscapeUtils.unescapeHtml4( 
          StringEscapeUtils.unescapeJava( resultActivity.get(TITLE).getAsString())));