[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.

Similar Posts: