Search code examples
javaant

Ant compile: unclosed character literal


When I compile my web application using ant I get the following compiler message:

unclosed character literal

The line of offending code is:

protected char[] diacriticVowelsArray = { 'á', 'é', 'í', 'ó', 'ú' };

What does the compiler message mean?


Solution

  • Java normally expects its source files to be encoded in UTF-8. Have you got your editor set up to save the source file using UTF-8 encoding? The problem is if you use a different encoding, then the Java compiler will be confused (since you're using characters that will be encoded differently between UTF-8 and other encodings) and be unable to decode your source.

    It's also possible that your Java is set up to use a different encoding. In that case, try:

    javac -encoding UTF8 YourSourceFile.java