Enjoying Java and Being More Productive with IntelliJ IDEA

Every time I visit a Java conference or a meetup and talk to people unfamiliar with IntelliJ IDEA, I get similar questions again and again: “What’s so special about IntelliJ IDEA? What does IntelliJ IDEA has that other Java IDEs don’t?” In response I usually simply demo a few of its features and then just watch their jaws dropping.

But you know, repeating this over and over is a bit counter-productive, so I’ve written this guide to sum up everything you need to know why IntelliJ IDEA is hailed as the most intelligent and user friendly Java IDE, which can and will make you a more productive developer.

Deep insight into your code

When you’re writing code, IntelliJ IDEA is busy with building its syntax tree, creating references between classes, variables, fields, methods, and their usages, analyzing the execution flow, and lots of other things. Using this information, it can provide completion, help you quickly navigate thru your code, and, of course, provide error analysis and offer handy quick fixes.

When you open a project for the first time, it takes a while to build these indexes, but after it’s done, IntelliJ IDEA offers blazing fast and intelligent experience by automating all the routine tasks and letting you focus on the creative part of your work.

Any of the modern IDEs will give you a more or less similar feature set: code completion, refactorings, and navigation, but only IntelliJ IDEA leverages the power of deep static code analysis at its most to make coding assistance way more intelligent and efficient.

Completion

Everyone knows that completion is a number one feature for any IDE. IntelliJ IDEA brings you several completion types that are really something, because they are based on the deep code intelligence mentioned earlier, and therefore are able to save you a lot of time (and typing.)

Smart completion

Call it via Ctrl+Shift+Space (Cmd+Shift+Space for OSX), to get a list of suggestions of classes, variables, fields and methods already filtered by the type compatible with the current context.

why_smart_completion

Static members completion

If you don’t remember class name with a static method or a constant, just start typing that constant name and call code completion twice. IntelliJ IDEA will give you a list of classes containing members with the name you’re looking for, and when you choose to use one of the variants, it will automatically add required import statements.

why_static_members_completion

Chain completion

Imagine symbols in current context do not have a value of compatible type, but some of their children do. Invoking Smart Completion twice in a row will give you a list of these choices, saving you the time that would otherwise be spent looking for a suitable expression.

why_chain_completion

Data flow analysis

When offering completion variants, IntelliJ IDEA also analyses possible data flow to guess the possible runtime symbol type and provides choices based on it, automatically adding class casts.

why_data_flow

Statements completion

IntelliJ IDEA can automatically add required parentheses, brackets, braces, delimiters and apply necessary code formatting. To see how it works, try typing “if” and pressing Ctrl+Shift+Enter (Cmd+Shift+Enter for OS X).

Instant completion

In IntelliJ IDEA you often even don’t need to call completion explicitly. When you start typing any character, it will instantly start suggesting the most relevant options.

Injected languages

Language injection is a feature that brings coding assistance for a language to expressions and literals in another one. For example, you can have fragments of SQL, JPQL, XPath expressions, HTML, CSS, JavaScript or any other language within String literals of Java code.

why_injected_languages

If you define a datasource in IntelliJ IDEA, you will get code completion for SQL expressions, based on its actual table schemes.

why_injected_sql

Refactoring

The nice side-effect of having the code syntax trees and their relationships indexed is that it makes IntelliJ IDEA able to manipulate these trees to apply complicated refactorings across many languages, expressions, and dialects.

For example, when you call Rename refactoring on a class within a JPA statement, IntelliJ IDEA recognizes that you need to rename a JPA entity class, and applies changes to the class and every JPA or other expression in the project—in a matter of seconds.

why_rename

Detecting duplicates

IntelliJ IDEA knows your code so well it can detect duplicate blocks on the fly.

why_duplicates

If you extract a variable, constant, or method, the IDE will check if there are other similar code within the scope that could be replaced with the new variable, constant, or method as well.

why_duplicates_2

Smart extract of String literals

If you select a fragment of a String literal and call one of the Extract refactorings, IntelliJ IDEA will create a constant and replace its usages across the code with references to it.

why_string_literals

Selection

In the most cases, you don’t even have to bother selecting the statement you want to refactor (e.g. extract, move, rename or inline): IntelliJ IDEA will guess the statement automatically or will offer you to choose from a list of available variants.

why_select_expression

Undo refactorings

IntelliJ IDEA can easily rollback even the most complicated refactorings–with just one click. So it’s perfectly safe to experiment with the code in any way you like.

Developer ergonomics

Every aspect of IntelliJ IDEA, its features, functions, UI layout, and integrations were all specifically designed to maximize developer ergonomics. IntelliJ IDEA is built around the idea that every minute a developer spends in the flow is a good minute, and things that break developers out of flow are bad things.

Every design and implementation decision considers the possibility of interrupting developer’s flow and seeks to eliminate or minimize it.

Unobtrusive intelligence

A good example of IntelliJ IDEA flow friendly design is when you reference any class, static method or a constant, IntelliJ IDEA takes care of the import statement up there at the head of the file while you keep coding away where you are.

If it sees that you have just done something that’s a potential problem, a little light-bulb pops up on a sideline. You can ignore it and just keep typing (which is quite often appropriate), or you can see what’s wrong by just pressing Alt+Enter.

why_unobtrusive

Ergonomic layout

Yet another good thing about IntelliJ IDEA is that most of your time the editor (and the code) is the only thing visible on your screen, and you don’t need to leave it to do something that isn’t coding-related, including generating code, switching between tool windows and project files, and even debugging.

why_inline_debugger

The column running down the leftmost side of the code editor is called the “gutter” and provides useful information and quick access to actions that let you navigate through code, execute it, manage breakpoints, and do much more.

Having the inline debugger, the gutter and shortcuts for every action allows for layout where you have more screen space because auxiliary controls like toolbars and windows can be hidden.

You can always maximize the editor by pressing Ctrl+Shift+F12 (Cmd+Shift+F12 for OS X). To restore the layout, press the same shortcut again.

Accessing a tool window via its shortcut moves the input focus to it, so you can use all keyboard commands in its context. When you need to go back to the editor, just hit Esc.

No save button

The most controversial, yet one of the greatest features of IntelliJ IDEA is that it saves all changes automatically, so you never need to worry about losing any of it. If you decide to rollback anything, you can always do it by using Local History. Even if you apply a complex refactoring that affects many files, you can quickly Undo it with one click.

Heuristics

Like everything else in IntelliJ IDEA, actions are designed for better ergonomics too. The first call is supposed to provide most expected results. Need more results? Press the shortcut again and the IDE will go deeper to find what you need.

why_heuristics

Actions that recognize this behavior include Basic Completion, Smart Code Completion, Navigate To Class, Navigate to File, Navigate to Symbol, Structure popup and some others.

No wizards

In IntelliJ IDEA you don’t have to walk through complex wizards or fill huge forms to get things done.

why_no_wizards

When you’re in the Project tool window, you can not only navigate through the existing items, but also create new ones by just pressing Alt+Ins (Cmd+N for OS X).

why_create_new

New users usually think that Navigation Bar is just a breadcrumb, but more experienced developers know that there’s a lot more to it. After you jump to it via Alt+Home (Alt+Up for OS X), you can use it to navigate over the entire project structure; create and change files, preview their content, and do many other useful things.

why_navigation_bar

No perspectives

IntelliJ IDEA has no perspectives like other IDEs (e.g. Eclipse) do. You don’t need to switch between different layouts to do different tasks. IntelliJ IDEA follows your context and brings up the corresponding tools automatically. Added benefit is that since there are no perspectives, all the shortcuts and actions stay the same all the time.

Quick search

All lists, trees and popups in IntelliJ IDEA provide you with quick search that instantly takes you to a set of items that contain text you’re typing in them.

why_speed_search

FAQ

Built-in developer tools

Terminal, Coverage, VCS, Decompiler, Bytecode viewer, Database, FTP, Application servers

Top frameworks are supported out of the box

Java EE, Spring, Android, GWT, Vaadin, Play, Grails, Hibernate, Thymeleaf, AngularJS, React, Velocity, Freemarker, Struts, Guice, JavaFX, Swing

All platforms

Windows, Mac OS X, Linux

Plugins

When you work with IntelliJ IDEA, usually you don’t need any plugins, because the most useful functionality is available out of the box. Yet, IntelliJ IDEA has a rich plugin ecosystem and mature plugin developer API.

Free and commercial editions

For pure Java, Groovy, Scala, Kotlin and Android development–there is a free and open source IntelliJ IDEA Community Edition. For web and enterprise development, we offer commercial IntelliJ IDEA Ultimate (30 days of free trial and more if needed). If your company needs a group trial for longer period, contact us and we’ll provide it shortly.

Feedback

Something is broken or you have a feature request? Submit an issue to our tracker, and we’ll do our best to get the problem fixed as soon as possible. For customers (and in fact for regular users too) we have a support channel where we help with questions and other important problems.

How easy is it to migrate from another IDE?

It’s difficult and may take some time (for some a week, for others a month or longer). Be sure when done, it will pay off with everyday productivity boost and enjoying your work. For migration from Eclipse, read this guide.

Good or bad but there is no better way to learn IDEA than by downloading it and actively trying it. If you work in situations where time is most definitely money, and sustained productivity is the measure of success, you can do worse than to take a good look at IntelliJ IDEA.

References

Develop with pleasure!

About Andrey Cheptsov

Part-time dreamer. JVM/JavaScript geek. IntelliJIDEA Marketing Manager at JetBrains.
This entry was posted in Tips & Tricks. Bookmark the permalink.

20 Responses to Enjoying Java and Being More Productive with IntelliJ IDEA

  1. Carsten Otto says:

    Great article!

    PS: You forgot to add the inline link for the Eclipse migration article.

  2. Dmitriy says:

    Funny… Very few of these are reasons I use IntelliJ. Here is my list:

    – no complex views (eclipse workspaces, etc)
    – graceful crashes — intellij at worst has to rebuild its indexes and do a full project rebuild on a crash. Eclipse can lose my entire workspace.
    – Every effort is put in to prioritize characters appearing on the screen when I press them on the keyboard. In Eclipse often there are delays and it is a mystery why.
    – Performance. Performance. Performance. The UX is very responsive. I don’t need to wait for a full rebuild when attempting to save. Etc.
    – No wizards. This is definitely a time save and I can keep using the keyboard most of the time.
    – A coherent small set of well supported plugins. IJ doesn’t have a billion plugins, the core ones are maintained by JetBrains and they follow a coherent UX paradigm. In eclipse half of the stuff I use daily looks, feels, behaves differently, and often suffers from performance.
    – Configuration sharing. I’m still getting the hang of exactly what to share, but overall I can get a developer up and running in ~ 15 minutes from scratch vs hours in eclipse.

    • Ben says:

      >>> – Every effort is put in to prioritize characters appearing on the screen when I press them on the keyboard. In Eclipse often there are delays and it is a mystery why.
      >>> – Performance. Performance. Performance. The UX is very responsive. I don’t need to wait for a full rebuild when attempting to save. Etc.

      Out of curiosity, what programming languages are you using? Also what OS?

      Because I *love* all Jetbrains IDEs, *however* performance is definitely not something I’ve ever appreciated. I have a Macbook Pro i7 with 16GB of RAM and have modified IDEA’s Java runtime settings (to give it more RAM – otherwise it hang on large project, particular CLion). Nonetheless, I’m always having problems with performance. Literally the opposites to the experience you just described. I press a key and I have to wait a long time for IDEA to catch up. Regularly I see IDEA thrashing 2 or 3 of my computers CPUs non-stop for over an hour. Fans blaring in the background. I often get stuck waiting for indexing when opening large projects.

      I regularly program in IDEA, Android Studio, AppCode and on occasion in CLion. All these IDEs suffer from the same problem. Ruby (IDEA plugin) support seems to be one of the worst culprits, but I get pretty serious issues with Javascript projects as well. Android Studio (Java) is probably the most responsive of the lot.

      Perhaps this is an issue on OS X?

      • Dmitriy says:

        Macbook Pro, Java, Groovy, Spring (this is a HUGE problem for eclipse)

        • Dmitriy says:

          Also I need ~ 1/2 the ram to run IJ than I need for smooth Eclipse operations.

          And I used RubyMine before, it is leagues beyond even the closest Eclipse based editor in terms of useful features, and performance.

          • Ben says:

            Totally agreed.

            In terms of usefulness all Jetbrains IDEs are leagues ahead – Objective-C, Java, Javascript, Ruby etc.

            I was just a bit surprised to see comments about IDEA’s great performance.

            I haven’t run Eclipse in years (phew) so I can’t compare to Eclipse. However, based on my experiencing running Jetbrain’s IDEs (for over 3 years now); performance unfortunately doesn’t seem to be a huge priority. IDEA may well still be leagues ahead of Eclipse; but I see no reason why the main thread should ever be blocked when typing. Thrashing CPUs when the IDEs don’t even have focus is also peculiar.

            I’d say these are just bugs (and maybe they still are), but they’ve persisted for years across multiple machines (all OS X though). I still do love the Jetbrains IDEs and use them almost exclusively, but performance is by far my biggest gripe with them.

      • Marc Paquette says:

        Check your “ReservedCodeCache” setting on the JVM running IDEA : I suffered major jvm trashing when this setting was too low. Dependening on the version of jvm, when this “code cache” fills up, the jvm is switching off the JIT-compiler, thus the code is being mostly interpreted. For other versions of the jvm, other phenomenom occurs (which I don’t pretend to understand) but the important point is that when this cache fills up, the jvm does a lot more work to execute the code, leading to high CPU utilization.
        To check this while idea is running : fire up jconsole, connect it to the jvm running IDEA (in the list of “local process” for a new connection, it is usually the one without a name), go to the “Memory” tab, then select the ‘Memory Pool “Code Cache”‘ chart from the drop down list. Monitor this while running your IDEA and try to reproduce the slow down. Once reproduced, check the chart to see if usage went close to the max for the “code cache” : if it did, try re-running IDEA with a bigger “ReservedCodeCacheSize” parameter and go over the same process again.
        For instance, my IDEA is running with ‘-XX:ReservedCodeCacheSize=512m’.
        Default value is somewhat small (around 50m if I recall correctly), but it is probably already bumped up in idea settings, but might still be too low for bigger projects.

        • Ben says:

          Thanks for the info.

          I’ve definitely played with the JVM settings from time to time, but I don’t recall adjusting the “ReservedCodeCacheSize”. I’ll give it a go!

      • David Leppik says:

        If you changed the configuration file more than one version ago, it could be that your JVM configuration has been migrated as the IDE’s defaults have been bumped up, and your customizations are now allocating too little RAM. Try removing your config file and see if that clears it up. I know, because it’s happened to me.

        Also, if you’re running several IDEs at the same time, 16GB might not be enough RAM. Unfortunately you can’t get more than 16GB on anything less than a $4k Mac Pro. I’m constantly quitting IDEs and keeping an eye on Activity Monitor. As soon as I see that I’ve used virtual memory, it’s time to reboot.

  3. Mike Lawson says:

    I used Eclipse for years and years until I first used IntelliJ. I will never go back to Eclipse, Netbeans, or anything of the sort. IntelliJ for life.

  4. Stewart says:

    Corruption of Workspaces in Eclipse finally made me switch – as well as the End of the World special! I used IntelliJ back

    IntelliJ is far better for web development than Eclipse. Eclipse would choke on the Javascript in the project I was working on at the time – it was hideously slow and crashed Eclipse. IntelliJ – no problem, and would auto complete as well. CSS support, and various web framework support are also an improvement over Eclipse.

    Overall – you get what you pay for – Eclipse is rough around the edges, while, IntelliJ ( JetBrains Ides generally ) is far more polished.

    I’d rather pay for an IDE that is far more productive than something that is free and not as productive.

  5. Sebastian says:

    > – Configuration sharing. I’m still getting the hang of exactly what to share, but overall I can get a developer up and running in ~ 15 minutes from scratch vs hours in eclipse.

    Thats by far the most important point!

  6. Venkata Jaswanth says:

    I used Eclipse while I was in college. It was the first IDE I ever used. I was amazed by the amount of work it does on a developer’s behalf. It was a pretty nice one. When I switched to Idea, Initially I had to come over a big learning curve. I even changed the look and feel, shortcuts to match Eclipse (resistance to change I guess). But, after few weeks, I slowly got the hang of Idea and its shortcuts.

    It is getting better with each release. Idea 15 is awesome. It gives the best performance. Startup time is greatly reduced when compared to Idea 14. I am using it on Ubuntu 15.10.

  7. I’d say the same for Scala. Would never be successful writing it without IntelliJ.

  8. Dmitry Kandalov says:

    There are also many small features in IntelliJ which you get used to and don’t notice until you switch to another editor/IDE and start swearing at it.

    “Unobtrusive intelligence” made me create this issue though https://youtrack.jetbrains.com/issue/IDEA-152618
    Posting it here to get more votes : )

  9. Taylor says:

    You mention coverage is a built in feature. Is JUnit built in like in the newer versions of Eclipse?

  10. Oleg Andreych says:

    Why do we even need so much shortcuts for completion (e.g. Basic Completion, Smart Completion, Completion with bracets (whatever))? If smart completion is really smart I want to use it everywhere.

  11. Nelson says:

    Hi guys..

    Great article !
    In my opinion the most difficult to work with IntelliJ project is multi modules with maven projects.

Leave a Reply

Your email address will not be published. Required fields are marked *