I need to make this into a string in java:
Looks like it was moved in Apache Commons Lang 3 to ESCAPE_ECMASCRIPT in StringEscapeUtils.
https://commons.apache.org/proper/commons-lang/javadocs/api-3.4/src-html/org/apache/commons/lang3/StringEscapeUtils.html#line.74
It seems it moved yet again, now it is part of "commons-text" and is named:
StringEscapeUtils.escapeEcmaScript
But good it still exists.
Apache commons have a methods just for this in StringEscapeUtils : the escapeJavaScript
method.