Philipp Hauer's Blog

Engineering Management, Java Ecosystem, Kotlin, Sociology of Software Development

Moving from Eclipse to IntelliJ IDEA: Experiences and Findings.

Posted on Oct 31, 2016. Updated on Jan 20, 2019

I’ve worked with Eclipse for 7 years. Now I switched to IntelliJ IDEA and I’m extremely happy with this IDE. To my mind IntelliJ IDEA is definitely superior to Eclipse. In this post I show you why.

Moving from Eclipse to IntelliJ IDEA: Experiences and Findings.

TL;DR

  • It’s not one big feature that makes IntelliJ better than Eclipse. It’s the huge amount of many minor and major features that distinguishes IntelliJ IDEA from all others.
  • IntelliJ IDEA is just clever. It provides more and smarter quick fixes, intended actions, refactoring, code analysis, hints and warnings.
  • It provides a rich feature set out of the box. No fiddling around with cumbersome plugins.
  • The free community edition is sufficient for many Java projects.
  • A survey by Zeroturnaround shows that “IntelliJ is the number one IDE among Java developers”.

Why is IntelliJ IDEA superior to Eclipse?

Main Points

  • The IntelliJ family (including PyCharm, WebStorms) supports a lot of different languages. The quality of tooling for all supported languages (Python, Go, PHP, JavaScript, HTML, CSS, Kotlin) is extremely high.
  • IntelliJ acts smarter. Examples:
    • IntelliJ shows the name of a parameter when the argument is an expression or literal. E.g. do(overwrite=true, recursive=false) instead of do(true, false). This simulates named arguments, a nice feature known from other languages like Kotlin or Python. Named arguments significantly increase the readability of a method invocation.
    • IntelliJ’s “Quick Fix and Show Intention Actions” (Alt+Enter) is more powerful than Eclipse’ “Quick Fix” (Strg+1). An example is the smart handling of static imports. I only have to write “assertEquals()” and the Quick Fix suggests to import the class Assert statically. I don’t have to write the import manually.
    • When I rename a field of a class (using refactor rename), really everything is renamed including names of getter and setter, parameter names of the constructor and the setter and even variable names holding the return value of the getter. It’s awesome!
    • Renaming a package of a JPA entity leads to an adjustment of the test package and the package name in the persistence.xml! So IntelliJ also looks for strings in non-java files and changes them accordingly. This prevents a lot of errors.
    • You can also Crtl+click on a class name in a persistence.xml or spring application context xml to jump to the Java source file.
    • IntelliJ warns me, when I’m about to delete a xy.json which is still used somewhere in my code (string “xy.json”)
  • Many features are included out-of-the-box. No annoying fiddling around to get all necessary features up and running (SVN, Git, Maven, Gradle, multi clipboard, integrated terminal).
  • If there really is an editor missing (e.g. for yaml, Docker, Markdown, gitignore or shell files) IntelliJ suggest automatically the installation of the plugin. After one click and a restart the editor is ready. It works like a charm. Contrary in Eclipse, where you have to google for an appropriate plugin, search the update site URL (or search in the Marketplace – if you know the plugin name), trigger p2 and wait… until infinity, because p2 is as slow as a dead snail.

Others

  • There is a huge amount of refactorings and code analysis available. Just type Ctrl+Shift+Alt+T to show a windows with context sensitive refactorings.
  • Nice out-of-the-box checks and reviews (like Checkstyle). For instance when using the redundant public keyword in interface methods.
  • Many templates for generating code. You can tell IntelliJ to use Java7 Objects or Guava for creating toString(), equals() and hashCode(). You can also generate fluent setters instead of the normal one.
  • UTF-8 is default – even under Windows.
  • Smart debugger: values of variables or arguments are show directly in the code. So you don’t need to hover over the variable or expand a tree. No need for a dedicated debugging perspective.
  • Commenting out (Ctrl+7) works in every language (HTML, pom.xml/XML, YAML, JSON) out of the box, not just in Java.
  • Auto-espacing of quotes () when pasting a text that contains quotes into a Java string.
  • IntelliJ recognizes if the project files were changed externally (through mvn, git checkout or git stash) and gets along with it.
  • Auto-Completion shows also methods that contains the already typed letters, not only the methods starting with the letters. So aString.inde<Ctrl+Space> suggests both indexOf() and lastIndexOf(). Very useful for discovering APIs.
  • Smart Completion (Ctrl+Shift+Space) additionally to the normal auto completion (Ctrl+Space)

Eclipse Features that IntelliJ IDEA Lacks

  • Triggering the Hot-Code-Replacement while debugging. In Eclipse you just save a file and Eclipse tries to hot-replace your code. In IntellliJ you don’t save explicitly, but you can trigger a compilation of the file (Ctrl+Shift+F9). The result is the same. However, the workflow in Eclipse feels a little bit more easy.
  • The dependency tree of the Maven integration (m2e) nicely shows all (transitive) dependencies, the version conflicts and their resolutions. I miss this feature in IntelliJ. The available community plugin Maven Helper for IntelliJ lacks usability and sometimes shows wrong conflict resolutions. That’s why I’m now using the command line (mvn dependency:tree and mvn dependency:resolve).
  • Eclipse compiles always the whole project. So you immediately see compile errors (especially after changing Maven dependencies). IntelliJ only compiles on demand, which is faster, but sometimes it takes a while until an error pops up. But you can compile the whole project by pressing Ctrl+Shift+F9.
  • In some projects IntelliJ is fairly slow and unresponsive for a while after I update Maven dependencies. So I disabled auto import of Maven dependencies and trigger “Import Changes” manually.

Tips for Migrating from Eclipse to IntelliJ IDEA

General Tips

  • First of all, read Migrating From Eclipse to IntelliJ IDEA.
  • Consider the Plugin Key Promoter to learn IntelliJ’s shortcuts.
  • Use Ctrl+7 for commenting out code: Per default IntelliJ uses Ctrl+/ for this. Just go to Settings > Keymap and reassign the action “Comment with Line Comment” to Ctrl+7.
  • Missing workspace concept: Basically, you should only open one project at a time in IntelliJ. But you can add other projects as modules into the current window. Workspace resolution also works fine in this situations. How to do this:
    • For Maven projects: Open the Maven toolbar in the right sidebar, press the + icon and select the pom.xml of the project you wish to include.
    • Generic approach: File > Project Structure > Modules >, then +.

Configure Eclipse “CamelHumps” Behavior

How do I get the same “CamelHumps” behavior in IntellIJ as in Eclipse? First of all, “CamelHumps” in terms of Eclipse means…

  • that double-click on the word “useSpec” selects the whole word, not only “use” or “Spec”, but
  • when the caret is at the left most side of “useSpec” pressing Ctrl+Right jumps before “Spec”, not to the end.

Necessary configuration:

  1. Don’t activate: Settings > Editor > General > Smart Keys > Use “CamelHumps” words
  2. Change keymap shortcuts:
    • Move Caret to Next Word in Different “CamelHumps” Mode: Ctrl+Right (remove other actions)
    • Move Caret to Previous Word in Different “CamelHumps” Mode: Ctrl+Left (remove other actions)
    • Delete to Word End in Different “CamelHumps” Mode: Ctrl+Delete
    • Delete to Word Start in Different “CamelHumps” Mode: Ctrl+Backspace
    • Move Caret to Next Word with Selection in Different “CamelHumps” Mode: Ctrl+Shift+Right
    • Move Caret to Previous Word with Selection in Different “CamelHumps” Mode: Ctrl+Shift+Left

Save Actions

Since IntelliJ saves the current file automatically, you don’t need to press Ctrl+S. The downside of this is that there are basically no save actions possible. In Eclipse it is sometimes handy to hook actions like “Formatting” or “Organize Import” to the save. But there are alternatives in IntelliJ doing the trick for me:

  • Formatting: You can hit Ctrl+Alt+L manually. But actually I rarely use the formatting action, because IntelliJ formats smart enough on the fly while I’m coding.
  • Organize Imports: Press Ctrl+Alt+O. However, I also rarely need this because of the following configurations I made.
    • Enable “Add unambiguous imports on the fly” under Settings > Editor > General > Auto Import.
    • Check “Optimize Imports” in the commit window (“Commit Changes”). So unused import will be removed before you commit.

Do I Need the Commercial Ultimate Edition?

Well, it depends on your project. But for many project I would say no. I have developed the first couple of months with the free community edition and never felt that I’m missing a feature. Some features of the ultimate edition are:

  • Web/Application Server tooling: I’m developing backend microservices based on Dropwizard and Spring Boot. So we are using the fat jar approach and don’t need application server support. However, if you use an application server (my sympathy!), you may need the ultimate edition. But I haven’t tested it.
  • Spring tooling: It’s useful, but not really necessary.
  • I only switched to the Ultimate edition because I had to make some changes to our legacy system which is written in PHP. And PHP tooling is a feature of the Ultimate edition.
  • The ultimate edition supports a huge amount of frameworks and deployments. Especially the Java EE stack could be important for many developers. But take a look at the comparison matrix.

The bottom line is that you can start with the free community edition and see how far you come.

Useful Shortcuts

Shortcut Action
Alt+Enter Quick Fix and List of Intention Actions
Ctrl+N Open Type
Ctrl+E Open Recent
Ctrl+Shift+N Open File
Alt+F7 Find Usage
Ctrl+F12 Navigate Current File (“Outline”)
Shift+H Hierarchy
Shift+F6 Rename
Ctrl+D Duplicate Line
Ctrl+X Cut Line (can be used to delete a line)
Ctrl+Shift+V Paste from Multi-Clipboard
Ctrl+Q Show JavaDoc
Alt+Insert Generate (in Editor); New (in Project Structure)
Ctrl+Alt+Left/Right Jump back/forward
Ctrl+E Recent Files
Ctrl+Shift+F Full Text Search
Ctrl+P Show Parameter Name (good for long argument lists)
Ctrl+Alt M/F/C/V Extract to method/field/constant/variable. Use in conjunction with Ctrl+W to get the right selection.
Ctrl+Alt+N Inline Variable
Ctrl+B (on fields or class names) Find usages in Quick Window. Considers Getter and Setter.
Ctrl+B Jump To Definition
Ctrl+Alt+B Navigate to Implementation
Ctrl+Alt+O Organize Imports
Ctrl+Shift+F9 Compile (triggers hot code replacement in debug mode)
Ctrl+W Escalate Selection
Ctrl+Shift+W Reduce Selection
Ctrl+Shift+Alt+T Refactor this (opens a window with possible refactorings)
Shift Shift Search everywhere
Shift+Enter Start New Line (useful when there is still something like “);” behind the cursor. Avoids usage of End key)
Shift+Alt+Enter Insert New Line before
Ctrl+Shift+A Search all Commands in IntelliJ, Execute Action
Ctrl+Shift+Space Smart Type Completion