IntelliJ idea the encoding problem when you compile the. java file under the project __ data area

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.