Error: The character encoding GBK unmappable solution

error

Today in cmd tests java code when I encountered an error
Here Insert Picture Description

Solution:

Enter javac -encoding utf-8 filename .java
Here Insert Picture Description

the reason:

Since the JDK is the international version, when we use javac compiler, the compiler will first obtain our operating system default encoding format (GBK) used, and then put the Java JDK source files from GBK encoding formats into internal default Java Unicode format placed in memory, then the converted file javac Unicode format class files compiled into class, this time, the class file is a Unicode encoding, temporarily stores it in memory, subsequently, the JDK encoded in Unicode format this class files save to the operating system we see the formation of class file. When we set it without compile-time, equivalent to using parameters: javac -encoding GBK BRRead.java, incompatibilities will arise.

Published 254 original articles · won praise 70 · views 180 000 +

Guess you like

Origin blog.csdn.net/zhizhengguan/article/details/104071073