Java Productivity Tips
Choosing the right IDE can significantly improve your development experience. Among Java developers, IntelliJ and Eclipse are the top picks. From my experience working with over 40 people across various teams, 99% of them use IntelliJ, and they do so for good reasons.
However, I’ve noticed that many people are unaware of some of IntelliJ’s great features, which have significantly improved my experience as a developer. In this post, I’ll share some of these tips.
1. Don’t restart your server after you modify a class
Starting a Spring Boot application can take a while, and restarting it after each class change during debugging can add up to a lot of wasted time.
When you’re fixing a bug or just checking how your server works, you typically make changes to the code and might feel inclined to restart the server to see if those changes resolve the issue. However, there’s no need to restart the server for your changes to take effect. You can just recompile the specific classes you changed, without having to restart everything.
From IntelliJ’s documentation:
You can reload a single class
You can also reload all modified classes
Keep in mind there are some Hotswap limitations. It will only work with non-structural code changes (changing an implementation of a method). HotSwap will not work when you change the class members or method signatures.
Given you’ll spend most of your time debugging as a developer, I highly recommend the entire ‘Debugging’ section from Intellij’s documentation, especially the Alter the program’s execution flow part.
2. Debugging backwards by exploring previous stack frames
Suppose you’re debugging and have set breakpoints in two methods: a()
and b()
. You’re inspecting b()
but suddenly realize you need to review something in a()
again. Instead of restarting the debug process, you can simply jump back to a()
to re-examine what happened there. This saves you time by letting you quickly revisit previous steps without having to go through everything again.
You are currently in b()
Now you are in a()
3. Resolving dependency issues with maven helper plugin
Managing dependencies in Java can get tricky, especially when there are conflicts. The Maven Helper plugin can be a big help here. It shows you where the conflicts are and lets you fix them fast.
For example, if you have two versions of a logging library that are causing problems, Maven Helper will point them out. You can then decide which version to keep, clearing up the conflict without having to dig through your project files manually.
4. Narrow down searches with file Masks
When looking for a word in your project, test files often show up too much in the results. To fix this you can use file masks. This allows you to tell IntelliJ which files you want to include or exclude in your search.
For example, if you’re trying to search for “user” but want to exclude test files, just apply the !*Test.java
file mask in your search. This filters out any files with ‘Test.java’ in their name, streamlining your results.
Search without file mask
Search with file mask
You can also customise the File Mask
value to your liking and exclude multiple file extensions.