Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij IDEA Java classes not auto compiling on save

People also ask

Does IntelliJ automatically compile?

Background compilation (auto-build)You can configure IntelliJ IDEA to build your project automatically, every time you make changes to it.

How do I stop auto compile in IntelliJ?

Open the Setting > Build Tools page. 2. Disable the "Reload changes in build scripts" option.


UPDATED

For IntelliJ IDEA 12+ releases we can build automatically the edited sources if we are using the external compiler option. The only thing needed is to check the option "Build project automatically", located under "Compiler" settings:

Compiler Settings

Also, if you would like to hot deploy, while the application is running or if you are using spring boot devtools you should enable the compiler.automake.allow.when.app.running from registry too. This will automatically compile your changes.

Using Ctrl+Shift+A (or +Shift+A on Mac) type Registry once the registry windows is open, locate and enable compiler.automake.allow.when.app.running, see here:

enter image description here


For versions older than 12, you can use the EclipseMode plugin to make IDEA automatically compile the saved files.

For more tips see the "Migrating From Eclipse to IntelliJ IDEA" guide.


Please follow both steps:

1 - Enable Automake from the compiler

  • Press: ctrl + shift + A (For Mac + shift + A)
  • Type: make project automatically
  • Hit: Enter
  • Enable Make Project automatically feature

2 - Enable Automake when the application is running

  • Press: ctrl + shift + A (For Mac + shift + A)
  • Type: Registry
  • Find the key compiler.automake.allow.when.app.running and enable it or click the checkbox next to it

Note: Restart your application now :)

Note: This should also allow live reload with spring boot devtools.


WARNING

Eclipse Mode plug-in is obsolete and is not compatible with the recent IDEA 12+ builds. If you install it, IDE will hang on every file change and will respond extremely slow.


IntelliJ IDEA doesn't use automatic build, it detects errors on the fly, not via compiler. Similar to Eclipse mode will be available in IDEA 12:

Make project automatically

Use Build | Make, it invokes the incremental make process that will compile only changed and dependent files (it's very fast).

There is also a FAQ entry that may help.

Update on the automatic make feature: When run/debug configuration is running, Make project automatically has no effect. Classes on disk will change only on Build | Make. It's the core design decision as in our opinion class changes on disk should be always under user's control. Automatic make is not the copycat of Eclipse feature, it works differently and it's main purpose is to save time waiting for the classes to be ready when they are really needed (before running the app or tests). Automatic make doesn't replace the explicit compilation that you still need to trigger like in the case described in this question. If you are looking for different behavior, EclipseMode plug-in linked in the FAQ above would be a better choice.


You can keymap ctrl+s to save AND compile in one step. Go to the keymap settings and search for Compile.


There is actually no difference as both require 1 click:

  • Eclipse: manual Save, auto-compile.
  • IntelliJ: auto Save, manual compile.

Simplest solution is just to get used to it. Because when you spend most of your daytime in your IDE, then better have fast habits in one than slow habits in several of them.


I ended up recording a Macro to save and compile in one step, and keymap Ctrl+s to it.


I managed to solve this using macros.

I started recording a macro:

  • Click Edit - Macros - Start macro recording
  • Click File - Save All
  • Click Build - Make Project
  • Click Edit - Macros - Stop macro recording

Name it something useful like, "SaveAndMake".

Now just remove the Save all keybinding, and add the same keybinding to your macro!

So now, every time i save, it saves and makes a dirty compile, and jRebel now detects all changes correctly.