1

I'm trying to move my Maven-Application from Eclipse Java EE Luna to IntelliJ Idea 14.0.3.

When i try to build the Project in my new Idea IDE i receive for this pice of code the following Error:

Error: java: duplicate case label

char c = '-';
int postChar = -1;

switch (c) {
case 'ü': c = 'u'; postChar = 'e';
    break;
case 'ö': c = 'o'; postChar = 'e';
    break;
case 'ä': c = 'a'; postChar = 'e';
    break;
}

What's wrong with this Code ?

Regards

Konstantin Yovkov
  • 62,134
  • 8
  • 100
  • 147
blub
  • 359
  • 6
  • 23

1 Answers1

3

I suspect it is a problem with the encoding setting. Try the following:

  1. Go to Setting (Ctrl+Alt+S / ,) > Editor > File Encodings. Make sure "Project Encoding" (at the top) is set to "UTF-8". You probably also want to set the "IDE Encoding" to UTF-8 as well.
    • You may also want to set this in File/Application > Other Settings > Default Settings so future new projects default to those settings.
  2. At the bottom right of the status bar (lower right corner), make sure the file's encoding is UTF-8. If not, change it:

enter image description here

  1. If the above does not solve the issue, go to Setting (Ctrl+Alt+S / ,) > Build Execution, Deployment > Compiler and in the "Additional build process VM Options" add -Dfile.encoding=UTF8. Also make sure that "Use compiler" at the top is set to javac. If you need an alternative compiler, you may have to troubleshoot the problem with that compiler. I would at least try the javac compiler so you can definitively say its an issue with the alternative compiler.
    • As an alternative, you can set the JAVA_TOOL_OPTIONS system/environment variable so it declares -Dfile.encoding=UTF8 and then restart IntelliJ IDEA so it picks up the change. After that all java and javac commands will use the file encoding setting. See the SO post Setting the default Java character encoding? for more detail.
  2. The above should work. If it does not, try replacing the char declarations with Unicode escape sequences as a troubleshooting step:

    switch (c)
    {
        case '\u00FC':
            c = 'u';
            postChar = 'e';
            break;
        case '\u00F6':
            c = 'o';
            postChar = 'e';
            break;
        case '\u00E4':
            c = 'a';
            postChar = 'e';
            break;
    }
    
Community
  • 1
  • 1
Javaru
  • 30,412
  • 11
  • 93
  • 70