IntelliJ IDEA is an integrated development environment for Java applications from the company JetBrains. It is positioned as the most intelligent and most convenient Java development environment with support for all the latest technologies and frameworks.
IntelliJ IDEA is one of the top three most popular Java IDEs along with Eclipse IDE and NetBeans IDE.
IntelliJ IDEA's terms of service
Since the first version of IntelliJ IDEA in January 2001, JetBrains has been adding new features and improving existing ones.
Starting with version 9.0, IntelliJ IDEA is available in two flavors:
- Community Edition
- Ultimate Edition
The Community Edition is a free version under the Apache 2.0 license. It is intended for JVM and Android development, as well as for developing applications with a graphical user interface (GUI). It is useful both to novice developers for educational purposes and to professionals for commercial development.
The Ultimate Edition is available under a commercial license and supports more tools than the Community Edition. This version is intended for enterprise and web development. It will be useful for backend and frontend developers.
For the next six months, the Community Edition will be adequate for you.
IntelliJ IDEA is available for three platforms: Windows, macOS, Linux. You can download the latest version from the official JetBrains website.
Why does different code run for me?
This is one of the most common questions that newbies have. The issue here is IntelliJ IDEA's Run Configuration.
The IDE offers several ways to run your code (your main method):
Just click on the Run button next to your main method or the class containing the main method.
Right-click on the file in the project tree. Then select Run…
Run with advanced options.
Beginners often have difficulties when using the third method. After running various files, IDEA instead creates a run configuration for each file/class and saves it to a list of "run configurations".
If you select some setting and press Edit Configurations…, we will see advanced run settings:
These settings let you specify which version of Java you want to use to run the program, and you can add additional environment settings or program arguments. Program arguments are the arguments that are passed to the main() method.
What a convenient feature! But this is precisely the source of the most common issue encountered by beginners, i.e. "Different code is running for me".
The problem arises if you press the Run button when a run configuration that does not match our file is selected:
To avoid this mistake, select the desired file/class name from the drop-down list.
Tools for working with code in IntelliJ IDEA
IntelliJ IDEA has many tools for working with code. We provide examples of a few of them below.
The Live Templates feature lets the developer significantly reduce the time spent writing frequently used code constructs.
For example, to create a main method, just type psvm in the editor and press the TAB key:
-> tab ->
Hotkeys can greatly simplify and accelerate coding. But you have to know the hotkeys to benefit from them. Here are a few key combinations that will serve you well now or in the near future.
Ctrl + Space — Shows a list of options to complete your input.
Ctrl + W — Smart text selection. First, it selects the word where the cursor is, and then the nearest whole statements, and so on up to the entire document.
and so on.
Ctrl + Y — Deletes the whole line, while keeping the cursor at the same position.
Ctrl + Shift + Space — Same as Ctrl + Space, but accounts for static fields and methods. It also helps to initialize a field with an appropriate type.
Ctrl + B — Jumps to the declaration of a field, method, or class. Produces the same effect as pressing Ctrl + LMB:
Ctrl + / — Comments out a line of code. If multiple lines are selected, this key combination will comment out the entire selection:
Shift + F6 — Renames a field, method, or class in all places where it is used.
Ctrl + Q — In a popup window, shows the documentation for a method, so you don't have to go searching through the source code. This helps to understand the input parameters and return value.
Shift + Shift (Double Shift, i.e. quickly press Shift 2 times in a row) — Search for everywhere for everything (well, it looks for classes and files, but not methods). This is helpful when you remember seeing something somewhere and even remember a couple of letters from the name — this window will help you find it.
When searching for classes, you can enter part of the name or only the first 2 letters in CamelCase. For example, BuRe will find BufferedReader:
Ctrl + Shift + V — A smart paste operation that remembers the last few items you copied.
Ctrl + Shift + Space — Smart auto-completion that suggests options for substituting values based on context.
Ctrl + Shift + A — Searches for an action. If you suddenly forget the hotkey for an action but remember its name, you can find any action and then run it.
Ctrl + Alt + M — Extracts the selected piece of code into a separate method. This hotkey is super helpful for refactoring.
Alt + Enter — Auto-completion that solves any problem. Really, it almost always helps. If you get some compilation error and you don't know the exact solution, the first thing to do is to see what IDEA suggests.
Alt + Insert — Automatically generates anything and everything: methods, constructors, classes...
Ctrl + O — Overrides a parent's methods.
Ctrl + K — When working with Git, commits.
Ctrl + Shift + K — When working with Git, pushes.
Ctrl + Alt + S — IDEA settings.
Ctrl + Alt + Shift + S — Project settings.
This is far from an exhaustive list of IntelliJ IDEA's useful functionality. In future lessons, we'll talk about many other useful features, including debug mode.