Over a million developers have joined DZone.

Enjoying Java and Being More Productive With IntelliJ IDEA

IntelliJ IDEA is a popular, and much-talked about integrated development environment (IDE). Here's an in-depth look at IntelliJ IDEA, from deep intelligence to FAQs.

· Java Zone

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

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 Intelligence

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 for 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 the 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 the 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 analyzes 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 data source 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 lightbulb 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 allow 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 a quick search that instantly takes you to a set of items that contain the 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 a 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.

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.

Topics:
java ,intellij

Published at DZone with permission of Andrey Cheptcov, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}