Java
Intellij IDEA Java classes not auto compiling on save
Are you experiencing the frustrating issue of your IntelliJ IDEA Java classes not auto compiling on save? This is a common problem that many Java developers encounter, leading to wasted time and disrupted workflows. It can be incredibly annoying to make changes to your code, hit save, and then realize that the changes aren’t reflected when you run your application. This often results in manual compilation, which slows down the development process considerably. The good news is that this issue is usually easily resolved with a few configuration tweaks or troubleshooting steps. This guide will walk you through the most common causes of this problem and provide practical solutions to get your IntelliJ IDEA auto-compiling your Java classes as expected, thus boosting your productivity and streamlining your coding experience. We’ll cover everything from compiler settings to project configurations, ensuring that you have a comprehensive understanding of how to fix this issue.
Understanding the Auto-Compilation Process in IntelliJ IDEA
IntelliJ IDEA is designed to automatically compile your Java code whenever you make changes and save them. This feature is crucial for a smooth and efficient development workflow. When auto-compilation is working correctly, IntelliJ IDEA monitors your project files, and upon detecting a save, it triggers the compilation process in the background. The compiled class files are then updated, allowing you to run your application with the latest changes without manually invoking the compiler. This seamless integration is one of the key reasons why developers prefer IntelliJ IDEA for Java development.
However, several factors can interfere with this auto-compilation process. Incorrect compiler settings, issues with the project configuration, or even conflicting plugins can prevent IntelliJ IDEA from automatically compiling your Java classes. Understanding these potential roadblocks is the first step towards resolving the problem. For instance, if the “Make project automatically” option is disabled, IntelliJ IDEA will not compile your code on save. Similarly, if there are errors in your code that prevent compilation, the auto-compilation process might silently fail. According to a JetBrains survey, nearly 20% of IntelliJ IDEA users face compilation issues at some point, highlighting the importance of understanding and troubleshooting these problems. Source: JetBrains Developer Survey.
The “Make” process, which includes compilation, is triggered by various events, including saving a file, running a configuration, or explicitly building the project. IntelliJ IDEA uses an incremental compilation approach, meaning it only recompiles the files that have changed or are affected by changes. This significantly speeds up the compilation process compared to recompiling the entire project every time. To ensure auto-compilation works as expected, it’s essential to configure IntelliJ IDEA correctly and address any underlying issues that might be preventing the compilation process from running smoothly.
Troubleshooting Common Causes of Auto-Compilation Issues
Several factors can cause IntelliJ IDEA Java classes not auto compiling on save. Let’s explore some of the most common culprits and how to address them. One frequent issue is incorrect compiler settings. If the “Make project automatically” option is disabled, IntelliJ IDEA will not compile your code upon saving. To check this setting, navigate to “Settings/Preferences” -> “Build, Execution, Deployment” -> “Compiler” and ensure that “Make project automatically” is enabled. This setting tells IntelliJ IDEA to automatically compile your project whenever changes are detected.
Another common cause is project configuration problems. Sometimes, the project’s module settings or dependencies might be misconfigured, leading to compilation errors or preventing auto-compilation. To verify your project configuration, go to “File” -> “Project Structure” and examine your modules, dependencies, and SDK settings. Ensure that all dependencies are correctly configured and that the project is using the correct Java SDK. A missing or incorrect SDK can definitely cause compilation failures. Consider upgrading your Java SDK to the latest stable release to benefit from performance improvements and security patches; this can resolve underlying issues impacting auto-compilation. Learn more about Java SDK upgrades.
Finally, conflicting plugins can also interfere with the auto-compilation process. Some plugins might introduce changes to the build process or conflict with IntelliJ IDEA’s built-in compilation features. To identify potential plugin conflicts, try disabling recently installed or updated plugins one by one and see if auto-compilation starts working again. If disabling a particular plugin resolves the issue, consider uninstalling it or looking for an alternative plugin that doesn’t cause conflicts. Furthermore, ensure your IntelliJ IDEA installation is up to date, as updates often include bug fixes and improvements that can resolve auto-compilation problems.
Step-by-Step Guide to Enabling Auto-Compilation
If you’re still struggling with IntelliJ IDEA Java classes not auto compiling on save, follow these steps to ensure auto-compilation is properly enabled:
- Verify “Make project automatically” setting: Go to “Settings/Preferences” -> “Build, Execution, Deployment” -> “Compiler” and ensure that “Make project automatically” is checked.
- Check for compiler errors: Open the “Build” panel (View -> Tool Windows -> Build) to check for any compilation errors. Address any errors to ensure successful compilation.
- Invalidate caches and restart: Go to “File” -> “Invalidate Caches / Restart…” and choose “Invalidate and Restart”. This will clear IntelliJ IDEA’s caches and restart the IDE, often resolving configuration issues.
- Review project structure: Go to “File” -> “Project Structure” and verify that your modules, dependencies, and SDK settings are correctly configured.
- Disable conflicting plugins: Disable recently installed or updated plugins to identify any conflicts that might be preventing auto-compilation.
This process should help resolve the majority of auto-compilation issues. Remember to save your settings after making any changes and test if the issue is resolved after each step. Sometimes, a simple restart of IntelliJ IDEA can also do the trick.
Here’s a featured snippet-optimized paragraph: To enable auto-compilation in IntelliJ IDEA, navigate to Settings/Preferences, then to Build, Execution, Deployment, and finally to Compiler. Ensure that the “Make project automatically” checkbox is selected. This setting instructs IntelliJ IDEA to automatically compile your project upon detecting changes, streamlining your development workflow. Correctly configuring this setting is crucial for a seamless coding experience.
Advanced Configuration and Troubleshooting Techniques
If the basic troubleshooting steps don’t resolve the issue, more advanced configuration and troubleshooting techniques might be necessary. One such technique is to examine the compiler settings in detail. IntelliJ IDEA allows you to configure various compiler options, such as the target bytecode version and the optimization level. Incorrectly configured compiler options can sometimes prevent auto-compilation from working correctly. To access these settings, go to “Settings/Preferences” -> “Build, Execution, Deployment” -> “Compiler” -> “Java Compiler”.
Another advanced technique is to use the “Build” menu to manually trigger a full project rebuild. This can help identify any hidden compilation errors or configuration issues that might be preventing auto-compilation. To perform a full rebuild, go to “Build” -> “Rebuild Project”. This will force IntelliJ IDEA to recompile the entire project from scratch, which can often resolve issues related to incremental compilation. Examining the build output in the “Build” panel can provide valuable insights into any errors or warnings that are occurring during the compilation process. Often, seemingly unrelated warnings can actually prevent compilation from completing successfully.
Finally, consider using a different version of IntelliJ IDEA or even a different IDE altogether as a test. While this is an extreme measure, it can help determine if the issue is specific to your current IntelliJ IDEA installation or if it’s related to your project configuration. If the problem persists in a different environment, it’s likely that the issue lies within your project’s configuration or dependencies. Consider seeking help from online forums or communities for further assistance. Stack Overflow is a great resource for troubleshooting IntelliJ IDEA issues. Visit Stack Overflow.
- Review project structure for misconfigured modules or dependencies.
- Temporarily disable plugins to identify conflicts.
- Manually trigger a full project rebuild.
FAQ: IntelliJ IDEA Auto-Compilation Issues
- Why is my IntelliJ IDEA not auto compiling my Java classes?
- Several reasons can cause this, including disabled auto-compilation settings, project configuration issues, compiler errors, or conflicting plugins. Review the troubleshooting steps outlined in this article.
- How do I enable auto-compilation in IntelliJ IDEA?
- Go to "Settings/Preferences" -> "Build, Execution, Deployment" -> "Compiler" and ensure that "Make project automatically" is checked.
- What should I do if I get compilation errors?
- Open the "Build" panel (View -> Tool Windows -> Build) to check for any compilation errors. Address any errors by correcting the code or resolving dependency issues.
- Could a plugin be causing the issue?
- Yes, conflicting plugins can sometimes interfere with the auto-compilation process. Try disabling recently installed or updated plugins to identify any conflicts.
- Will upgrading IntelliJ IDEA help?
- Upgrading to the latest version of IntelliJ IDEA can resolve bugs and improve performance, potentially fixing auto-compilation issues.
I am using JRebel with WebSphere Server 7 as well.
Everything now seems to be working somewhat fine, except that when I modify a Java file, and hit save, IntelliJ does not re-compile the file, in order for JRebel to pick it up.
The Eclipse “Build Automatically” feature resolved this issue.
In IntelliJ IDEA, I have to hit CTRL+SHIFT+9 to re-compile the relevant class for JRebel to pick it up. If changes are done across two files, I have to do this on each and one of them and since IntelliJ uses the save all mechanism, its pretty hard to know what to recompile manually which I am not really interested in doing either.
Isn’t there a way to make IntelliJ to do this on its own?
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:
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.
For versions greater than 2021.2, we need check ‘Allow auto-make to start even id the development application is currently running’ option: 
For versions older than 2021.2:
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:
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.

