Complete Guide How To Migrate From Eclipse To IntelliJ IDEA

Speaking about best IDEs or programming languages can similar to religious dispute. All sites defend their opinion and points. Eclipse vs IntelliJ IDEA is a similar discussion. In my opinion this should be a matter of personal choice - as far you are satisfied by the results.

In this post:

Eclipse vs IntelliJ IDEA 2018

It's difficult to find accurate and updated statistics about the usage of those two IDEs. Many key factors play role as:

  • primary IDE or supportive
  • programming language
  • company culture
  • price
  • frameworks
  • performance

From my personal research I think that IntelliJ IDEA comunnity is increasing. Some people claim that market share of IntelliJ is bigger other insist of equal share for Java.

Acording to stackoverflow.com survey for 2018 IntelliJ is taking 24.9% while Eclipse is 18.9% from all respondents.

The versions on which is based this review are: Eclipse Neon / Oxygen and IntelliJ IDEA 16 / 17 community edition

Similarities

Eclipse and IntelliJ are mature and have long history in Java world. Both IDEs are feature rich and include many tools which can ease your life:

  • Auto Complete
  • Templates
  • Debugger
  • Themes
  • Plugins
  • Support of multiple languages
    • testing with python scripts shows that both are capable of editing, showing and executing Python scripts.
  • Refactoring

If you need to work on a Java project there are high chances of choosing on of them as development tool

Differences

The differences between Eclipse and IntelliJ IDEA are the thing which can make your decision for one of them. Providing a full and precise list of all differences is a difficult task. So I'll try to give them from my personal experience (at least the major one).

  • Project View - personally I prefer using the IntelliJ way of openning a single(or several) projects and focusing on the project instead of working with Workspaces. This difference can be considered more as convetion: Project vs Workspace and Module vs Project.
    • Eclipse - in Eclipse you can open many projects at once in a single working window. You can search in all of them and view code from several projects simultaneously. In Eclipse you are working with workspaces which contains several projects
    • IntelliJ IDEA - A project is the working level for IntelliJ. You can open several separate windows with different projects. You can search in a single project. You can add several projects in IntelliJ as modules.
  • Memory - My personal experience with small Java projects (about 80 MB), gradle, spring boot is that IntelliJ has better memory management. This comparison is more complicated because of the project view for both of them
    • Eclipse - 8 GB RAM are enough to work with several projects and DB server without big issues
    • IntelliJ - it seems to utilize better RAM. With similar configuration (8 GB RAM, tested on Ubuntu) - compiling and running project is faster in IntelliJ.
  • Stability - The reason to move from Eclipse to IntelliJ was the frequent crashes of Eclipse. The crashes were project and OS independend( Windows and Linux). IntelliJ is far more stable working with medium size projects and version control.
  • Version control - The other reason to move from Eclipse to IntelliJ was the git integration. I faced many problems like: hanging commits, broken pushes, mixing branches, losing code versions and unintuitive user interface. In IntelliJ I was able to integrate git very fast and without problems.
  • Keymaps or shortcuts - this is another boring thing which should be mentioned as difference. The good point here is that you can customize a lot and even use profile from another IDE.
  • Conventions and Settings - there are many settings which you need to set up when you are using an IDE. In my personal experience with Maven / Gradle / Spring Boot/ Grails in IntelliJ - I can faster and easier to set up new project and fix problems in configuration like missing SDK.
  • No perspectives - These can be a big surprise for new developers comming from Eclipse. After a few days of using IDEA are enough to accustom to No perspectives way of working.

Import Eclipse project in IntelliJ IDEA

If you wan to import existing eclipse project to IDEA you can follow to the recomended way:

  • File
  • New
  • Project from Existing Sources
  • Select directory with existing sources
    • Eclipse project (.project) or classpath (.classpath) file
    • OK
  • Create project from external model
    • Eclipse
  • Select new project files location
  • Select Eclipse Project to import
  • Import code style from Eclipse - optional
  • Select project SDK
  • Finish

You can read and follow the on-screen instructions if you need to have better control on the project import.

Integrate IntelliJ Idea with version control

Integrating IntelliJ with version control is easy task. It is installed by default and you don't need to install plugins in order to make it work. You may need only to install git (or other) on your OS. This is one of the advantages of IntelliJ in front of Eclipse. Version control integration just works without problems, it's user friendly and intuitive.

  1. Open your project in IntelliJ
  2. Menu
  3. VCS
  4. Enable Version Control Integration
  5. Select version control system:
    • Git
    • CVS
    • Mercurial
    • Subversion
  6. Select Git and press OK -now you will see more options in your main menu / CVS menu.
  7. Add remote main menu / CVS / Git / Remotes
  8. In git repositories - click + - adding new remote
    • put the address from the bitbucket repository:

https://yourusername@bitbucket.org/yourusername/projectName.git

* Test ( you may need to provide password) and press OK.

IntelliJ open multiple projects

If you want to work with several projects like in Eclipse you can open them in several different windows. This can be done by:

  • File
  • Open
  • Choose your project
  • You will be asked where to open the project:
    • New projects can either be opened in a new window or replace the project in the existing window. How would you like to open the project?
  • Select New Window

Eclipse shortcuts in IntelliJ

Shortcuts for most of the commands are different between these two IDE-s. This is one of the hindrance to a move from one IDE to another. There is a good point which is:

You can use your Eclipse shortcuts in IntelliJ by setting a keymap

How to setup Eclipse keymap in IntelliJ IDE:

  • File
  • Settings - CTRL+ALT+S
  • Keymap
  • Select Eclipse keymap

You can also customize specific Commands

  • File
  • Settings - CTRL+ALT+S
  • Keymap
  • Search for a command
  • Select a command
  • Remove or Add keyboard shorcut

IntelliJ Templates

Templates are very useful feature which is another difference between Eclipse and IntelliJ. You can view templates in IDEA by pressing:

CTRL+J

For example templates for

System.out.println();

is

  • type - sout
  • TAB

and for:

public static void main(String[] args) {
}

is

  • type - psvm
  • TAB

IntelliJ Useful Shortcuts

  • search everywhere - double SHIFT - this will search the entire project. You can use this to find files from a given type - for example getting all XML files - *.xml

  • recent files - CTRL+E - This is a view of all recently used items.

  • recent edited files - CTRL+SHIFT+E - This is a view of all recently modified items. It can be used if you stop using tabs.

  • search class - CTRL+N - this will search for classes.

  • search file - CTRL+SHIFT+N - This one is searching for any file which is matching your constraints

  • Find in file - CTRL+F - search only in current file

  • Replace in file - CTRL+R - if you want to replace something in the current file scope.

  • Syntax aware selection

    • extend - CTRL+W
    • decrease - CTRL+SHIFT+W
  • Comments

    • comment - CTRL+/
    • uncomment - CTRL+/
    • Multiline comment - CTRL+SHIFT+/
  • Block selection (Pure block selection):

    • Press and hold: ALT
    • Select with left mouse button
    • Now you can copy, paste or delete
  • Code Completion - CTRL+Space

  • Smart Type Completion - CTRL+SHIFT+Space

  • Go to Declaration - CTRL+B - Use this to navigate to the declaration of a class, method or variable used somewhere in the code

  • Rename file - SHIFT+F6

  • Highlight Usages in File - CTRL+SHIFT+7

  • Search for action or command - CTRL+SHIFT+A

  • Show Intention Actions - ALT+ENTER - similar to Eclipse quick fix

  • Introduce variable - CTRL+ALT+V - Refactoring, to create a variable from an expression.

    • Introduce variable - CTRL+ALT+L - Reformat and optimize imports

Code formatting

Eclipse code formatting differ from IDEA. You can import the Eclipse formating while you are importing your project(check section import project) or change the settings in general. To change code formatting style you can do:

  • File
  • Settings
  • Editor
  • Code Style
  • Java ( or any other language)
  • Customize your preferred settings

Importing Eclipse settings is done by:

  • File
  • Settings
  • Editor
  • Code Style
  • Java ( or any other language)
  • Click the gearwheel
  • Import Scheme
  • Eclipse XML Profile

Tips to ease your migration to IDEA

  • Change the keymap - in order to make your life easier at the beginning you can change the default keymap to IntelliJ. This will decrease the migration pain and will speed up your transition.
  • Formatting - Keep the eclipse formatting at least for your first days in the new IDE for older projects. For new projects try to learn the new way of formatting.
  • Create new empty projects - In order to start working with the new IDE you can create and play with new empty or test projects. Try to mess up and fix the project.
  • Before migration - do a copy of your projects in the older IDE format. You ca use also version control to make this move more secure.

Conclusion

In 2018 the move from Eclipse to IntelliJ may seems natural for developers who want to try something advertised as fast, intelligent and stable. To be honest I'm still using Eclipse for some of my old projects - since I don't want (have time or will) to migrate all my older projects from Eclipse. Both IDEs are good enough to met most developers expectations.
Some specific requirements like version control and development tool stability could force programmers to change their camp. Still in 2018 IntelliJ is showing better performance and productivity for professional and seasonal developers.
My advice is if you want to move to another IDE - do a test for several hours on a new empty project. See the basics commands and actions. For IntelliJ you can test the Community Edition which is free and good enough for most projects ( it lacks support for .css and javascript and some other minor features)

Reference

Related Article