尝试编译 java 时出现非法字符:错误 187 191
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17363308/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Illegal Character when trying to compile java : error 187 191
提问by Erkhemee Enkhtaivan
I'm trying to compile java to class and I'm getting error, this is the some first lines
我正在尝试将 java 编译为类,但出现错误,这是第一行
/* */ package gcb;
/* */ import gcb.bot.ChatThread;
/* */ import gcb.bot.SQLThread;
/* */ import gcb.plugin.PluginManager;
/* */ import java.awt.event.ActionEvent;
/* */ import java.awt.event.ActionListener;
/* */ import java.net.InetAddress;
/* */ import java.text.SimpleDateFormat;
/* */ import java.util.ArrayList;
Im getting error like this, please someone help me. Can anyone solve this problem remotely? Please i need to solve this problem ASAP
我收到这样的错误,请有人帮助我。谁能远程解决这个问题?请我需要尽快解决这个问题
C:\project>javac GChatbot.java
GChatbot.java:1: error: illegal character: 7
/* */ package gcb;
^
GChatbot.java:1: error: illegal character: 1
/* */ package gcb;
^
2 errors
Please help me
请帮我
回答by Xie
Save your file without byte order mark.
保存没有字节顺序标记的文件。
回答by Suresh Doraiswamy
Saving the source file as ANSI will solve this problem. It did for me. The source file can be created using Notepad and saved as xx.java in the ANSI format. Best Wishes
将源文件保存为 ANSI 将解决此问题。它对我有用。可以使用记事本创建源文件并以 ANSI 格式保存为 xx.java。最好的祝愿
回答by Santiago
What Xie says is the correct answer, since the error is in the first line, where byte order mark is located.
谢说的是正确答案,因为错误在第一行,字节顺序标记所在的位置。
What I had to do was to save the file as ANSI. But after this several errors appear because ANSI codification does not include several characters of foreign languages, therefore I had to manually correct inside the IDE the special characters that were all over my comments and documentation. That fixed the problem.
我必须做的是将文件保存为 ANSI。但是在这之后出现了几个错误,因为 ANSI 编码不包括外语的几个字符,因此我不得不在 IDE 中手动更正我的评论和文档中的特殊字符。这解决了问题。
回答by user3236650
Save your file as ANSI (encoding). Thus you can get correct
将文件另存为 ANSI(编码)。这样你就可以得到正确的