IntelliJ IDEA 2020.1 was released in April 2020 and represents the first major update of the year. Here are the 5 key new features that every Java developer should know about.
1. Automatic JDK download
Fed up of endlessly searching for the right JDK online? This new feature integrates the downloading of JDKs directly into the IDE.
You can choose to download from a list of vendors including OpenJDK and AdoptOpenJDK:
And you can choose from many different JDK versions:
Once the download has finished, you can toggle your project between JDK versions like normal:
Accessing the automatic JDK download feature
This feature can be accessed from several locations in the IDE, including:
- from the File > project structure dialog under SDKs:
- from the tooltip which appears when you have no JDK configured:
2. Code Vision
When navigating around large codebases you may find yourself searching for usages and implementations all the time. In IntelliJ IDEA 2020.1 code vision automatically brings this information to the editor inline.
You’ll benefit from information about usages and implementations directly next the the code declaration. You can click the text to show a list of usages or implementations then jump to the one you’re interested in:
Note that if it’s just a single usage or implementation, clicking the link will jump straight to the relevant code. ✅
Enabling Code Vision
Code vision has to be enabled in File > Settings > Editor > Inlay Hints > Java > Code Vision. You can choose to show hints for usages and inheritors (or in other words implementations):
3. Split terminal
If you’re a stickler for the command line, you can now split the terminal both vertically and horizontally to make the most of your screen real estate.
Just right click on the terminal tab to open the context menu to see the split options:
Here, for example, I’ve chosen to split the terminal vertically:
4. LightEdit mode
IntelliJ IDEA 2020.1 is not only a great Java IDE but its editor works well for viewing all sorts of different types of files, from XML to YAML. Previously if you wanted to open a single file you had to open it in a project, but now you can open just the file itself in LightEdit mode.
This mode is like IntelliJ IDEA but without the usual toolbars and fluff you’d associate with the full IDE:
Accessing LightEdit mode
Files can be opened in LightEdit mode from the IntelliJ IDEA welcome screen. Select Open or Import and then choose the file:
You can also open a file in LightEdit mode by:
- using your operating system’s context menu. In Windows just right click the file, select Open with, then choose IntelliJ IDEA.
- running the relevant
ideacommand. For example, in 64-bit Windows I run
idea64.exe <file-name>. This assumes the IntelliJ IDEA bin directory is in the
5. In-editor JavaDoc rendering
If you’re browsing through code it’s no fun trying to read un-rendered JavaDoc style comments with it’s tags and custom syntax. IntelliJ IDEA 2020.1 allows you to render JavaDoc in the editor making for a much nicer reading experience:
Enabling in-editor JavaDoc rendering
To enable JavaDoc rendering go to File > Settings > Editor > General > Appearance then tick the Render documentation comments on file opening option and click save:
These three additional features didn’t quite make the top 5 list, but they’re worth knowing about anyway.
In-place method refactoring
If you change a method name or signature without using refactoring tools, a gutter icon will appear asking if you want to make the change to all of a method’s usages:
The same functionality can also be accessed from the quick fixes menu (
Alt + Enter). Depending on how you work this feature might be useful, but for renaming at least the
Shift + F6 shortcut is still quicker.
Debugger code prediction
IntelliJ IDEA 2020.1 is now so clever that it knows what’s going to happen in your code before it happens! Dataflow analysis has been added to the debugger so that it can tell you about the future state of your application beyond the breakpoint on which you’re currently stopped.
For example, here I’ve stopped at a breakpoint on line 13 but IntelliJ IDEA is telling me that the
if statement condition on line 14 will return false:
Unfortunately for Gradle users the predictions only work when you have the Gradle option Build and run using set to IntelliJ IDEA.
Java 14 support
Java 14 introduces some nice language features, although admittedly some of them are still in preview mode. This means they may be changed or even removed in future Java releases.
IntelliJ IDEA 2020.1 supports these new language features, including:
- records which reduce boilerplate code by getting the compiler to generate accessor,
equalsmethods. Lombok, your days may be numbered! 😈
instanceofimprovements which allow you to test the type of a variable and assign it to a variable of that type in the same statement
- text blocks allowing multi-line String declarations using triple quotes
- new switch statement which offers a more concise syntax using
Download IntelliJ IDEA 2020.1 Community edition
Grab the free edition over at the JetBrains download site
IntelliJ IDEA documentation
See the full list of new features in the 2020.1 release over on the JetBrains website
If you prefer to learn in video format, check out the accompanying video to this post on the Tom Gregory Tech YouTube channel.