Home > Article > Development Tools > notepad++java code encoding gbk's unmappable characters
After using the notepad editor to write the java code, and then using javac to compile it, such an error occurs! (Recommended learning: notepad )
The code is as follows:
The error is as follows Picture:
Error reason:
Since the JDK is an international version, when compiling, if we do not Use the -encoding parameter to specify the encoding format of our JAVA source program. Then javac.exe will first obtain the encoding format used by our operating system by default. That is, when compiling a java program, if we do not specify the encoding format of the source program file, JDK will first Obtain the file.encoding parameter of the operating system (it saves the default encoding format of the operating system, such as WIN2k, its value is GBK), and then JDK converts our java source program from the file.encoding encoding format to the JAVA internal default UNICODE format into memory.
Then, javac compiles the converted unicode format file into a .class class file. At this time, the .class file is UNICODE encoded, and it is temporarily placed in the memory. Then, JDK converts this file into a UNICODE file. The encoded and compiled class file is saved to our operating system to form the .class file we see.
For us, the .class file we finally obtained is a class file whose content is saved in UNICODE encoding format. It contains the Chinese string in our source program, but at this time it has been passed through file. The encoding format is converted to UNICODE format.
When we compile without setting, it is equivalent to using the parameters: javac -encoding gbk XX.java. Of course, incompatibility will occur.
Solution:
Menu: Settings→Preferences→New, select the encoding method as ANSI.
The above is the detailed content of notepad++java code encoding gbk's unmappable characters. For more information, please follow other related articles on the PHP Chinese website!