2

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!

  • Don't put the javadoc jar in your `lib`. Keep documentation separate from working jars. – RealSkeptic Sep 19 '15 at 10:12
  • Removed it, problem still stands though. –  Sep 19 '15 at 10:25
  • There is no unescapeHtml in the class. And the import will not let you call the static method unescapeJava without prefixing it with the class name. – laune Sep 19 '15 at 10:28

1 Answers1

1

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())));
laune
  • 31,114
  • 3
  • 29
  • 42