Question: I print hindi characters as string in java and I'm getting an error. I save the java file in notepad uing UTF-8.

```
public class MainClass {
    public static void main(String args[]) throws Exception {
        String s = "साहिलसाहिल";

        System.out.print(s);
    }
}

```

After compilation, I get 2 errors of illegal character. Why so?

Answer: 
Try compiling like this:

```
javac -encoding UTF-8 MainClass.java

```

Make sure that you use the correct name for the encoding too. 

If this fails, it is likely that the problem that the Notepad is adding a BOM at the front, and that is confusing the java compiler. If that is your problem, you should stop using Notepad for editing UTF-8 files. Use a decent text editor that doesn't add a BOM to UTF-8 files.
try it with

`java -Dfile.encoding=UTF8 MainClass.java`