java org.apache.commons.text.stringescapeutils - Why was org.apache.common.lang3 StringEscapeUtils deprecated?

java.lang.noclassdeffounderror: classnotfoundexception (5)

Per the deprecation listing, it was moved to a new project -- commons-text

I couldn't find any explanation why StringEscapeUtils was deprecated from Apache Lang3 v3.7.

What are we supposed to use now for HTML escaping/unescaping

The class was moved from package




You can replace the deprecated library easily:

In your build.gradle:

implementation 'org.apache.commons:commons-text:1.6'

And in your class using StringEscapeUtils make sure you import the correct class:

import org.apache.commons.text.StringEscapeUtils;

1.6 is currently the newest version (from Novebmer 2018) but you can check the versions at maven:

From Commons-lang 3.6 release notes:

The Apache Commons Community has recently set up the Commons Text component as a home for algorithms working on strings. For this reason most of the string focused functionality in Commons Lang has been deprecated and moved to Commons Text. This includes:

o All classes in the org.apache.commons.lang3.text and the org.apache.commons.lang3.text.translate packages o org.apache.commons.lang3.StringEscapeUtils o org.apache.commons.lang3.RandomStringUtils o The methods org.apache.commons.lang3.StringUtils.getJaroWinklerDistance and org.apache.commons.lang3.StringUtils.getLevenshteinDistance

For more information see the Commons Text website:

Do below steps

  • Add below dependency to your pom.xml (if using maven)

  • Import correct package as below
    import org.apache.commons.text.StringEscapeUtils;

  • There is no such method unescapeHtml() in this class anymore, instead its two variations are available unescapeHtml3() and unescapeHtml4()
  • Use unescapeHtml3() to unescape Html 3.0 characters
  • Use unescapeHtml4() to unescape Html 4.0 characters

I generally use serialVersionUID in one context: When I know it will be leaving the context of the Java VM.

I would know this when I to use ObjectInputStream and ObjectOutputStream for my application or if I know a library/framework I use will use it. The serialVersionID ensures different Java VMs of varying versions or vendors will inter-operate correctly or if it is stored and retrieved outside the VM for example HttpSession the session data can remain even during a restart and upgrade of the application server.

For all other cases, I use


since most of the time the default serialVersionUID is sufficient. This includes Exception, HttpServlet.

java apache-commons apache-commons-lang apache-commons-lang3