Compared with the real-time automatic compilation of Eclipse, the compilation of IntelliJ IDEA is more manual. Although IntelliJ IDEA can also enable real-time compilation by setting, it is too wasteful of resources, so it is not recommended to do so. In addition to manually clicking the compile button to compile the IntelliJ IDEA compilation method, you can also configure a compile event before the "container" runs, first compile and then run. By default, IntelliJ IDEA is also set like this, so in actual development, we don't need to pay too much attention to compiling. Although IntelliJ IDEA does not compile on the fly (when not set), this does not affect the automatic checking of the code. However, for the association between multiple classes, it is still necessary to wait Build
or Rebuild
trigger the relevant inspection.
- Note 1: Build Project, compile the project;
- Note 2: Build Module, compile module;
- Note 3: Recomplie, recompile the class file;
- Note 4: Rebuild Project Rebuild the project.
As shown in the figure above, in IntelliJ IDEA, there are three ways to compile:
- Build : Compile the selected target (Project or Module), but only the modified files will be compiled, the unmodified files will not be compiled.
- Recompile : Perform mandatory compilation of the selected target (Java class file), regardless of whether the target has been modified.
- Rebuild : Perform mandatory compilation on the selected target (Project), regardless of whether the target has been modified or not. Since the target of Rebuild is only Project, each Rebuild takes a long time.
Next, let's take a look at the compilation before running:
As shown in the figure above, IntelliJ IDEA operates by default before running the project Build
.
So, let's take a look at the settings and choices of the IntelliJ IDEA compiler:
- Note 1: Set the automatic compilation project;
- Note 2: Set the compile-time
heap
size; - Note 3: Set the
VM
parameters at compile time.
As shown in the figure above, we navigate to the " Build, Execution, Deployment > Compile " page, and by checking the one shown in Note 1Build project automatically
, we can set IntelliJ IDEA to compile automatically; Note 2 means setting the compilation heap
size, the default is 700, if you use For a 64-bit machine, if there is enough memory, you can try to modify it to 1500 or more. In addition, if we report an OutOfMemoryError
error when compiling, we can also modify (reduce) this parameter; note 3 means to set the compile time The virtual machine parameters, which can be customized according to the needs, under normal circumstances, the default can be used.
As shown in the figure above, we are located on the " Build, Execution, Deployment > Compiler > Excludes " page, and you can add or delete directories (or files) for compilation and exclusion by clicking the sum shown in Note 1 . When compiling the project, if any of the compilable files are not compiled, then IntelliJ IDEA cannot run, and IntelliJ IDEA can only run after all the problems are solved and the compilation is passed. However, it is possible that during the development process, the file compilation of a certain package directory cannot pass, but we are not in a hurry to change it. At this time, we can consider adding the package to the exclusion compilation list, so that the project can be run. La!+
-
- Note 1: Use compile;
- Note 2: Project bytecode version;
- 标注3:Per-module bytecode version.
As shown in the figure above, we navigate to the " Build, Execution, Deployment > Compiler > Java Compiler " page, and mark 1 shows the compilers supported by IntelliJ IDEA, including Javac, Eclipse, Ajc, etc. The default is Javac, and Javac is also recommended ; Note 2 shows the compiled version for the project bytecode, generally the version of the main JDK of the current project is selected; Note 3 means that it can be set separately for Project
the Module
special needs of the following bytecode version
, of course, the premise is that our computer must be in advance Install the corresponding JDK version.
———— ☆☆☆ ——Back- >The easiest IntelliJ IDEA tutorial in history<- Contents—— ☆☆☆ ————