@Jayan do you realize that you changed the meaning of whole question ?
–
Suhail GuptaOct 11 '12 at 8:32

@ Suhail Gupta : sorry, I have fixed with better title. Essentially a file with unicode content is a different problem. When the same file is a java source code, fix is editor/using different encoding etc.
–
JayanOct 11 '12 at 8:44

@Jayan what are you doing ? what is java source file ? do you even understand what am i asking..
–
Suhail GuptaOct 11 '12 at 11:24

@Jayan now please do not make any edit to the question
–
Suhail GuptaOct 11 '12 at 11:35

3 Answers
3

The characters in the beginning of the file come from the the Byte Order Mark that some text editors like to insert into the beginning of a file. The Java compiler however does not accept files with BOM. You have two options:

Use a text editor that allows saving files in Unicode without BOM, such as Notepad++.

Use only ASCII characters in source code. Where you need Unicode characters use \uXXXX-escape codes. The JDK comes with a utility program to convert "native" text into this encoding, called native2ascii. For example,

The byte order mark (BOM) is a Unicode character used to signal the endianness
(byte order) of a text file or stream. Its code point is U+FEFF. BOM use is
optional, and, if used, should appear at the start of the text stream.
Beyond its specific use as a byte-order indicator, the BOM character may also
indicate which of the several Unicode representations the text is encoded in.

So You need to strip the BOM or convert your source file to another encoding. Notepad++ can convert a single files encoding, I'm not aware of a batch utility on the Windows platform for this.