Let's start with a simpler but also more egg-sore question.
background : I am a novice small white, beginner java.
problem : Compile a problem when writing Java files using UTF-8 encoded format.
Reason Analysis : 1, Java file Encoding format is UTF-8,WINDOWS7 system (the default encoding format is GBK) on the JDK to see, so error;
2, the first line should be public class P position turned into two wonderful Chinese characters, resulting in unresolved.
Workaround :
On the first question: Under the Windows7 system, create a new system variable (right-click on the Computer icon--Properties--left "advanced system Settings"--"advanced" environment variable--system variable--new), the variable is named Java_tool_options, The value of the variable is-dfile.encoding=utf-8. This way, each time you execute a Java class tool, the encoding format is temporarily set to UTF-8 (but you will not understand the corresponding error message), so this method is best to confirm that there are no other problems in addition to coding problems with OH).
On the second question: These two wonderful Chinese characters are actually due to Windows Notepad (well, I don't have to write Java anymore.) The default encoding format is ANSI, and turning into UTF-8 is not a purely UTF-8, but a "utf-8+bom" format. Yes, this BOM is the cause of the error. The recommended solution is to use the IDE class tool such as Eclipse, or a text editor such as EditPlus (simply say EditPlus this, in the tool-configuration (user) Customization Tool-left click on the file option, the right side can set the default format of the text, select UTF-8 on it).
Resolving garbled cases caused by default encoding conflicts between Java file encoding and Windows7 system (Chinese version)