Skip to content

Escape dollar sign ($) in Java Manifold String templates (

I have added Java library to our Maven Java project pom.xml:


After this the compilation of the following line:

String foo = "$HIS";

fails compilation:

[INFO] -------------------------------------------------------------
[ERROR] /c:/workspaces/dev/src/main/java/com/foo/bar/[26,24] cannot find symbol
  symbol:   variable HIS
  location: class
[INFO] 1 error

Obviously, this is Manifold String templates trying to find a variable named $HIS, which is not defined in scope. So, I need to escape the $ sign, because I need it to be part of the String literal. How can I do it? If I use $ then IntelliJ screams “Illegal escape character in string literal”.



The most elegant way I found was to use annotation @DisableStringLiteralTemplates from the same Manifold library:

import manifold.rt.api.DisableStringLiteralTemplates;

public class FooExample {

    public void sampleMethod() {
        String foo = "$HIS";
        System.out.println("Foo is " + foo);


Escaping the dollar with $ also works, just the IntelliJ plugin is required for the IDE to recognize all functions of the Manifold Java library.

A detailed description of Manifold String templates can be found here:

7 People found this is helpful