5

Is IntelliJ compiling all the time since it tells me with red squiggly lines when there is an error? (in addition to the autocomplete features) Or is it doing some sort of psuedo compiling?

If it is doing legit compiling, where does it put these compiled classes? I'de like to point my JRebel to that directory instead of the individual module target folders.

Carlos Bribiescas
  • 4,197
  • 9
  • 35
  • 66

5 Answers5

7

Meo is right, from what I learned when I developed plugins for custom languages, IntelliJ does not compile anything until you explicitly make your project. While you are typing, its lexer/parser detects any invalid token or code construct. In the meantime, it maintains an index of every class and method in your project and its dependencies, along with their signature, etc.

After you stop typing, you'll see a little colored eye in the top part of the right gutter. It indicates that the IDE is running "annotators" and "code inspections". They are able to tell whether or not classes, methods and variable are valid based on the current index and the current state of your file (imports, declarations, etc.). The same goes for unused variables, invalid parameters in method calls, etc.

Pros:

  • annotators work directly on what they call a PSI tree, which is basically an enhanced AST representing your current file
  • it may be faster that compiling every time (it uses an index and does not need to recompile every dependent class)
  • annotators can detect things javac don't care about, such as potential bugs (e.g. using = instead of == in a while condition)

Cons:

  • that's a loooot of work, basically they need to rewrite the logic to find every error that javac can produce (which is why you can find many issues on their bugtracker labelled "good code is red" or "bad code is green", meaning there is a difference between what they detect and what the compiler would output)

TL;DR: it does not produce any .class until you make your project, everything is done "by hand"

Bastien Jansen
  • 8,756
  • 2
  • 35
  • 53
4

For every module, the compiler output path can be found from Paths tab in Module Settings. JRebel plugin generates rebel.xml automatically and derives the directory path from Module Settings, so you do not need to point to the locations manually - just generate rebel.xml using the IDE plugin: right click on module in the project view -> JRebel -> generate rebel.xml

Anton Arhipov
  • 6,479
  • 1
  • 35
  • 43
  • Yes, when I tell it to compile it compiles to the directories in the generated rebel.xml. However it also appears to compile my code in real time instead of waiting for me to compile it. Where can I find those classes? – Carlos Bribiescas Jul 31 '14 at 12:37
  • AFAIK, when "make project automatically option" is turned on, IDEA will compile the classes exactly to the same location where it would compile those if you run the compilation process manually. – Anton Arhipov Jul 31 '14 at 21:31
4

Just to add, after compilation, the classes are stored in the target directory if it's a Maven project - otherwise, the directory is specified in IntelliJ's Project Structure, in "Project compiler output":

enter image description here

flow2k
  • 3,999
  • 40
  • 55
2

IntelliJ understands the code, it does not need to compile the code to know what is wrong.

Meo
  • 12,020
  • 7
  • 45
  • 52
0

I found my .class files by going to the out/production/main folders from the home directory of the project.

Weava
  • 31
  • 1
    out/production contains the classes **after** building/compiling manually. The question is, if classes are compiled automatically while typing, where are the compiled classes stored? – bcsb1001 Jul 30 '14 at 19:58
  • Doesn't answer the question that was being asked here, but it does answer the question that I had, and this question was the first result from my DDG search. I wanted to know where my individual .class files were - now I know they're in directory that's a sibling of src. – ArtOfWarfare Jun 09 '16 at 15:48