Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant compile: unclosed character literal

Tags:

java

ant

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?

like image 844
Mike Avatar asked Jan 27 '26 05:01

Mike


1 Answers

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
like image 137
Greg Hewgill Avatar answered Jan 28 '26 18:01

Greg Hewgill