error: illegal character: '\ufeff' in java

对着背影说爱祢 提交于 2019-12-08 03:30:03

问题


Got this error when compiled java code in ubuntu.

error: illegal character: '\ufeff'
import java.net.*;
^

error: class, interface, or enum expected
import java.net.*;
        ^

回答1:


As Jim Garrison pointed out, you probably have a Byte Order Marker (BOM) at the start of the file. Use an editor that can view all non-printable characters and remove it.

Alternatively, you can use sed to remove it:

sed '1s/^.//' infile >> outfile



回答2:


Use another editor because it seems to be an eclipse UTF-8-BOM problem. Convert the UTF type UTF-8.

And also I note that ; First it doesn't work for me and I convert the type ANSI and after convert type to UTF-8 format. It can be a another alternative solution for you



来源:https://stackoverflow.com/questions/45697794/error-illegal-character-ufeff-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!