Tagged: ide

Why and How to Migrate from Eclipse to IntelliJ IDEA

After years of programming Java with Eclipse, and multiple hints from other developers that IntelliJ IDEA is superior to Eclipse, I finally tried it out. Meanwhile, I’ve come to the conclusion that programming with IntelliJ is just so much more fun than with Eclipse. Here’s some Pros and Cons about IntelliJ compared to Eclipse and some tips on migrating from Eclipse to IntelliJ.

Pros

As I am writing this, I have been trying out Intellij for about 3 weeks after having used Eclipse for about 6 years. In those 3 weeks, I have come to love many small and big features of IntelliJ that Eclipse does not offer (at least not without searching for some plugin that does the job). Here’s the positive things I stumbled upon while trying out IntelliJ:

Responsiveness

My current (legacy) project at work consists of about 50 modules, one Eclipse project each. The number of projects combined with Dependency resolution through the IvyDE plugin, it appears that I am spending more time waiting that coding. After having migrated the project to IntelliJ, my workspace is much more responsive. Searching is blazingly fast. Everything just seems to work faster. IntelliJ is only doing the work it needs to do, instead of doing all the work in case that you might need the results in the future. Because of this, it also has a smaller memory footprint.

Flexible Project Structure

In Eclipse it has always been awkward to create projects with a nested directory structure. It works when first checking out the main directory from VCS as an Eclipse project and then importing all projects that are contained within the main directory. Then you have the code of all Eclipse projects twice in your workspace, though: once in the Eclipse project of the main directory and once in the actual Eclipse project… . The project structure in IntelliJ is completely up to you. You import a directory structure and define which sub directories your modules are in.

Smart Tooling

IntelliJ comes with many features helping you to navigate or refactor code. There’s a shortcut for selecting the current word, then the current statement, the current block, and so forth if used repeatedly. Also there’s a shortcut for surrounding the currently selected code with try-catch, if-else, for-loop or several other code snippets. Using both those shortcuts together is an enormous help when coding, if you ask me. Auto-completion is also available everywhere, even when you don’t expect it. IntelliJ auto-completes my Maven dependencies in the pom.xml by checking which artifacts are available in my local repository!

Seamless VCS integration

The integration to Version Control Systems like Subversion or Git feels right at home in IntelliJ. No more switching to the “SVN Synchronizing” Perspective in Eclipse. Just click update or commit and go through the VCS dialog, which shows you all information you need. You can move changed files into different change sets which you can commit separately. And you can perform certain actions like code analysis or reformatting on commit (code analysis is enabled by default, which has saved me from a couple certain bugs already!).

Interactive Editor

The code editor is very interactive and marks up warnings and errors prominently. You can recognize outdated javadoc immediately, since @param-descriptions of parameters that don’t exist are colored red. If you use String.format(), IntelliJ tells you when the placeholders in your format string don’t match the parameter list! If you compile a regular expression using Pattern.compile(), IntelliJ will tell you if the regex is valid and even offers to enter test strings to match against it! IntelliJ also marks unused variables, methods and classes – not just private ones, but also public ones.

Intelligent Usage of Screen Space

There are no “perspectives” as in Eclipse. If you start a debugging session, the debugging view will simply open at the bottom of the screen. If you start a unit test, the testing view will open. No more switching between perspectives.

Cooler looks

IntelliJ ships with a pretty cool theme called “Darcula”, which is made up of dark backgrounds and light font colors and is a lot of fun to work with. There’s a theme plugin for Eclipse, but it only allows theming of the editor window.

Cons

Of course, IntelliJ has some drawbacks, too. I have expected more than I found, though. Here’s the list of bad things I found while evaluating IntelliJ:

Buggy Dialogs

When changing settings for project modules in the Project Structure dialog, the changes are not always saved as I would expect, resulting in having to do it twice. May have to do with the plugins, I’m using, though (I’m suspecting IvyDEA).

Awkward Renaming and Adding of Packages

When you want to add a new Package to an Eclipse-Project, you are presented with a dialog in which you can edit the fully qualified package name. In IntelliJ you only get a single input field for the last element of the name of the package to add or rename. If you want to add a package at some level in between, you have to add a package to the source folder and type the fully qualified name by hand.

Awkward Renaming of Modules

Modules have a directory name in the file system and a name within the workspace. Each time you want to rename a module, you are asked whether to change the former or the latter – I have not found an option to change both at the same time…very frustrating.

Configuring Subversion Integration can be awkward

If you are working with Subversion, you currently have to check out the sources initially via IntelliJ. If you check out the sources with another tool (like TortoiseSVN) and then import it into IntelliJ, it won’t work because of working copy inconsistencies!

It’s not free

IntelliJ costs money. A commercial single developer license costs €450. Which is a lot (at least, when trying to persuade your boss). Licenses for Open Source work are free, though.

Migration tips

Here’s a couple tips that might be helpful when you come from Eclipse and are trying out IntelliJ:

Use the default Eclipse shortcuts

If you have worked for years with Eclipse it seems to much for me to re-learn all key bindings. IntelliJ provides a default key binding that is based on default Eclipse shortcuts. Simply choose it from the list of available Keymaps in the Keymaps settings.

Disable “Caret after end of line”

Coming from Eclipse, IntelliJ has the annoying default setting to allow navigating a line after the end of the line. So, when you navigate up or down the editor to a line that is shorter than the line before, the cursor will stay at the same column instead of jumping to the last character in the new line, as I have come to expect. You can change this in the  IDE Settings by disabling the option “Allow placement of caret after end of line”.

Use ALT+INSERT and ALT+ENTER!

Get acquainted with those shortcuts, they make working with code a breeze!

Show Javadoc on Mouse-Over

By default, IntelliJ doesn’t show the Javadoc of a class or method on mouse over. You can activate this by adding the following line to the file idea.properties in the installation folder:

auto.show.quick.doc=true

Add a Live Template for creating {@link}s in Javadoc

IntelliJ does support auto-completion of class names in Javadoc, but it doesn’t surround them with the {@link} annotation to create hyperlinks in the resulting Javadoc. To mitigate this, you can create a live template with the following text yourself:

{@link $LINK$}

Add a variable called LINK that expands to the expression “complete()” and give it the abbreviation “link” and set it to be only applicable in Javadoc. From then on, you can type “link” and then TAB to create a Javadoc link with auto-completion.

My Personal Conclusion

For myself, I have concluded to use IntelliJ from now on. It’s just so much more fun to work with! All I have to do is persuade my boss to spend some money on the licenses for my team and me… .