Tag Archives: GBK

[Solved] Java compilation error: unmapped character encoding GBK

Today, a helloworld.java source file is created by using the Echo instruction of the windows command line. The following errors are reported when compiling into a bytecode file:

Cause and solution: when javac compiles the source file, it needs to decode the source file. By default, the character encoding of the operating system is used for decoding. The simplified version of win11 uses GBK, so pay attention to whether GBK is used when encoding the source file. If there is only English, the encoding method of the source file is only compatible with ASCII code. Or you can change the character encoding during decoding through the command parameters of javac.

Javac reports error wakeonlan. Java: 19: error: unmapped character encoding GBK

Problem: javac reports error wakeonlan. Java: 19: error: unmapped character encoding GBK

Reason: the default code of windows is GBK, while the code of java file is UTF-8

resolvent:

    Open the java file with UltraEdit and check the code displayed on the status bar in the lower right corner. Here, confirm that it is UTF-8. Or copy the java file into eclipse, right-click and select properties to view its encoding

    If you confirm that the file code is UTF-8, add the coding parameter during javac compilation:

    javac -encoding UTF-8 WakeOnLan.java