The encoding problem when compiling. java files is known to require that a coding scheme be correctly specified when compiling the. javascript file, which is used to decode the byte stream of the. java file.
So how do you specify the correct encoding scheme when you compile all the. java files under the project using IntelliJ idea (assuming you use the JAVAC compilation tool)?
1 First, we need to know that when you execute the "make Project" command under the "Build" menu and compile the. java file under the entire project, IntelliJ the specific commands that the idea executes. We can get it by executing the "Generate Ant Build" command under the "Builds" menu, generating an ant building file, and then using this ant built file, we can get the IntelliJ Idea the specific commands that are executed when compiling the entire project. [1]
2) with the help of ant build file in 1, it is found that IntelliJ idea is executing a "javac command with various parameters" when the. java file under the project is compiled. There is a "-encoding" parameter, which is used to specify the encoding scheme that should be used when compiling the. java file, as shown in Figure 1. IntelliJ idea itself has a set of mechanisms to determine the value of the parameter, which, after testing, may come from the configuration of "Project Encoding", as shown in Figure 2, which is likely to come from a code scheme that a. java file was detected by IntelliJ idea, see link; It may also come from the compiler parameter configuration shown in Figure 3, and so on. The specific mechanism needs to consult the relevant documentation.
Figure 1
Figure 2
Figure 3
3) is available, IntelliJ idea itself has a mechanism for determining "-encoding" parameter values, but often the last determined value is not what we want. and the "encoding" parameter is a very important parameter, in order to more accurately specify the "-encoding" parameter, we can explicitly configure "-encoding XXX" in the compiler parameter configuration shown in Figure 3.
Reference documents:
[1]http://stackoverflow.com/questions/2966530/can-i-see-the-exact-commands-intellij-uses-to-build-a-java-project