java:[1,0] Illegal character: \65279 problem

Source: Internet
Author: User

The following error was reported when deploying the project

[Java]View Plaincopyprint?
  1. java:[ 1 0 ] illegal character:  \ 65279   
  2. JAVA:[1,10] class, interface, or enum expected
the surface looked at the document indeed. Don't see the problem, and later update the code from SVN. Found local also do not error. The Xxx.java class's properties were later viewed through eclipse, only to discover the mystery:

Compile problematic file attributes: ( note the following line Byte Order Mark is UTF-8 (BOM))


Compile the normal file properties:


It appears that the problem is on the Byte Order Mark is UTF-8 (BOM).

Because the problem is not visible, so open two files with UltraEdit. Display in 16 binary format:

Problematic file Header:


Problem-Free File header:

There seems to be a problem with the file header three bytes more than the EF BB BF.

Detailed reasons such as the following:

Some editors add a UTF8 tag to the UTF8 file (EditPlus called it a signature), which inserts three invisible characters (0xEF 0xBB 0xBF, or BOM) at the beginning of the file, which represents a Unicode tag (BOM). So the key to solving the problem is to remove this tag option, which can be done as in the following way.
Method One: First open this file with EditPlus. Choose Permanet Settings from the Doucument menu, there are three categories, each General,file, Tools. Click File, and on the right there is a UTF-8 signature: select Always remove Signature. Click OK.

The menu structure of the Chinese version number is editplus, such as the following: document-and-parameter settings, file->utf-8 signature, always remove signature, so that the UTF-8 format does not need to be marked in front of the file, Finally, save the file as Utf-8 format.

Mode two: Open Xx.java with notepad++, select the format of the menu bar---to UTF-8 no BOM format encoding, save the submission can be


Related information, online excerpt:

UTF-8 is a byte-coded unit with no byte order problem. The UTF-16 is encoded in two bytes, before interpreting a UTF-16 text. The first thing to figure out is the byte order of each encoding unit. For example, received a "Kui" Unicode encoding is 594E, "B" Unicode encoding is 4E59. Suppose we receive the UTF-16 byte stream "594E", then is this "Kui" or "B"? The recommended method for labeling byte order in the Unicode specification is the BOM. The BOM is not a BOM for "Bill of Material", but a byte Order Mark.

The BOM is a bit of a clever idea: there is a character called "ZERO WIDTH no-break SPACE" in the UCS encoding, which is encoded FEFF. While Fffe is not a character in UCS, it should not be present in the actual transmission. The UCS specification recommends that the character "ZERO WIDTH no-break SPACE" be transmitted before the byte stream is transmitted. This assumes that the receiver receives Feff, indicating that the byte stream is Big-endian, and assuming that the Fffe is received, it indicates that the byte stream is Little-endian. So the character "ZERO WIDTH no-break SPACE" is also called a BOM. The UTF-8 does not require a BOM to indicate byte order, but is able to use a BOM to indicate the encoding method. The UTF-8 code for the character "ZERO WIDTH no-break SPACE" is the EF BB BF (readers can verify it with the coding method we described earlier). So suppose the receiver receives a byte stream beginning with the EF BB BF and knows it's UTF-8 encoded. Windows uses a BOM to mark the way a text file is encoded. The original BOM was added a few bytes at the beginning of the file as a marker.


Extended reading:

UTF-8, UTF-16, UTF-32 & Bom:http://www.unicode.org/faq/utf_bom.html#bom

Official Description: Http://www.w3.org/International/questions/qa-utf8-bom

java:[1,0] Illegal character: \65279 problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.