In this chapter, we will compare IntelliJ IDEA editions and licenses, install the tool, and quickly introduce the main workspace. IntelliJ IDEA comes with many settings; it is not possible to cover all of them in one book so we will focus on the most important ones. We will cover the following topics in this chapter:
Comparing the various editions
Installing the tool
Configuration tips and tricks
IntelliJ IDEA is available as a free Community Edition and full-fledged Ultimate Edition. From the licensing point of view, the good thing is you can use both editions to develop the software you want to sell. It is worth mentioning that the new Android Studio that is used for the development of mobile Android applications is also based on IntelliJ IDEA.
The detailed comparison table can be found on the JetBrains website: http://www.jetbrains.com/idea/features/editions_comparison_matrix.html. To cut a long story short, there are many features missing in the Community Edition, but there are some workarounds available if you look close enough. For example, when you want to use Tomcat or Jetty servers in the Community Edition, you can use Maven plugins to run and debug your web applications freely. We will discuss this in Chapter 5, Make It Happen – Running Your Project.
You can use the Community Edition to develop applications using many frameworks such as Play, Struts, or Spring. It's all Java, after all. The IDE will not assist you in that. Most of the configuration hints, warnings, autocompletion, and runtime configuration features will be unavailable.
The Ultimate Edition, on the other hand, is the full-featured commercial IDE. You have the full support of almost all of the modern frameworks and application servers. The IDE will assist you by providing code completion, hints, and diagrams. The language support in this edition is also more comprehensive; you will get HTML and scripting languages analysis available on the fly, for example.
Apart from the provided features, the Ultimate Edition can be categorized based on the license. Depending on your needs, you can purchase any of the following licenses:
Personal license: IntelliJ IDEA can be used only by the person who purchased it. You can use it on as many computers as you own, as long as you are the only user. The Personal license, of course, can also be used to develop commercial products.
After opening the downloaded installation package in MS Windows, you should see the installation wizard. In Mac OS, double-click on the downloaded
.dmgfile and then just drag IntelliJ IDEA to the
During the first startup, IntelliJ IDEA will ask you which plugins should be enabled by default. Usually, it's best to enable only what you need, so the IDE loads and works faster with fewer plugins enabled. Don't worry if you don't know what to select; you can always change your mind later by editing the IDE settings. On the first startup, you will not be able to see the workspace without the project opened. While we will go through the details of creating the project in the next chapter, you can now just create the basic Java project by choosing New Project from the File menu, selecting Java, and proceeding with the New Project wizard by clicking on Next a couple of times.
Tool windows are those little "tabs" visible at the edges of the workspace. These edges are called tool window bars, as shown in the following screenshot:
Some of the tool windows are always available, such as Project or Structure, while some of them are available only when the corresponding plugins are enabled.
The tool windows have a context menu available when you right-click on them. The context menu contains items specific to a particular tool window and some possible view modes, as shown in the following screenshot:
The pinned tool window will stay open even when it becomes inactive by losing focus. You may prefer to have the Project tool window pinned to have a constant overview of the project structure. Only docked windows can be pinned. On the other hand, you can keep the project view closed almost all the time and simply use the keyboard shortcuts to navigate. On large projects, this approach is much faster than searching the tree manually for your file.
When docked, the tool window will share the total workspace area with other workspace elements such as the editor. On the other hand, when undocked, the tool window will overlap the other workspace elements when resized. An undocked window will go away if inactive. For example, it is especially useful to have the console tool window undocked and resized; reading huge logfiles or console output will be a lot easier.
Floating, as the name suggests, allows the tool window to float over the workspace and be detached from the screen edges. It may be useful when you work on multimonitor environments with huge display resolutions set. There are no limiting factors for the number of floating windows shown simultaneously. When floating, tool windows can be easily arranged to suit your needs.
The tool window will share the tool window bar with other tool windows when it has Split Mode enabled. This gives you the ability to see two tool windows at once. It's nice to see the project structure and file structure at the same time, as shown in the following screenshot:
When you use the Ctrl + left-click (PC) or cmd + left-click (Mac) keyboard shortcuts, the splitter between the two tool windows is displayed at once; IntelliJ IDEA will switch them to the wide screen mode and display them in a horizontal layout. It is priceless when you work on a fancy panoramic display and would like to use the screen space effectively, as shown in the following screenshot:
These views can be made visible as separate tabs by selecting Show views as tabs in the tool window context menu:
When you have your tool windows set up, it may be a good idea to back up your current layout. You can save the way the tool windows are currently arranged by navigating to Window | Store Current Layout as Default in the main menu. You can always load the saved workspace layout by navigating to Window | Restore Default Layout or pressing Shift + F12.
You can quickly open your last active tool window by using the F12 (PC) or Fn + F12 (Mac) keyboard shortcut. To make this shortcut work on Mac, you first need to adjust the F12 system shortcut behavior in the System Preferences window available in the Apple menu. To quickly hide/unhide all tool windows and focus on the editor, press Ctrl + Shift+ F12 (PC) or cmd + Fn + Shift + F12 (Mac).
When switched off, you can temporarily show the tool window bars by pressing the left Alt key (PC) twice or tapping and holding down the left cmd button (Mac). This way, you can switch tool windows swiftly and save screen space at the same time.
If the tool window contains a list (and most of them do, actually) to navigate or search inside the tool window, focus on the tool window, and just start typing the search text. It doesn't matter if it is a project or another tool window: IntelliJ IDEA will search for the characters you typed on the fly, as shown in the following screenshot:
This plugin makes tool window buttons available to be controlled on a per-project basis. It allows the creation of tool window profiles, that is, you can set specific tool windows to be hidden for one project and shown for another. This is the way to keep your IDE clean and tidy.
To access the settings, go to Window | Tool Window Management | Configure Preferred Availabilities from the main menu, as shown in the following screenshot:
An important part of the workspace is the editor tabs. They represent opened files and have a context menu with file-specific options, such as adding a file to a favorites list or using version control on the file.
Tabs are great to switch files, but there is a drawback here. They occupy some of the editor space when you have many files opened. The limit of the visible tab count can be set by navigating to Settings | Editor | General | Editor tabs (PC) or IntelliJ IDEA | Preferences | Editor | Editor tabs (Mac) dialog box. IntelliJ IDEA autocloses tabs if the tab count exceeds the defined limit. This is a very useful feature to reduce the tab clutter. IntelliJ IDEA will always close the least used tab.
Consider switching tabs off completely. It may sound a little weird at the beginning, but when you develop the habit of using keyboard shortcuts to navigate through opened files, you will not need tabs, and will regain some of the valuable editor space.
In the next section, we will discuss the options of the IDE—setting keyboard shortcuts, colors, fonts, and plugins.
The settings dialog is available from the main menu by navigating to File | Settings (PC) or IntelliJ IDEA | Preferences (Mac). You can also use the wrench icon on the toolbar or Ctrl + Alt + S (PC) or cmd + , (Mac) keyboard shortcuts. All of the settings are divided into two groups: one for project-specific settings (such as code style, version control, and so on) and one for global, IDE settings (such as appearance or HTTP proxy, for example).
There are many options here. The good thing is you can use the search field to search for a specific option. Just start typing the option name and the dialog box will be searched from top to bottom to present you the result.
For example, if you introduce a "typo" in the search box, you will be presented with the Inspection project settings, where you can turn the Spelling/Typo inspection option off. In the Editor/Colors & Font/General section, you can change colors for misspelled words.
IntelliJ IDEA is a keyboard-centric IDE. Any action you can do by using your mouse, you can do by using the keyboard as well.
There are some predefined keymaps available. Whether you come from using Eclipse or NetBeans, you can find your well-known keymap here and apply it. Please note that predefined keymaps are not editable. To modify the keymap, you must create and edit a copy.
When defining a new keyboard shortcut, the Second Stroke keyboard shortcut editor feature is very useful. You can use this to set up double strokes, easy to remember keyboard shortcuts, or even shortcut groups. You can define your base shortcut, such as Ctrl + Shift + O for example, and then numbers as second strokes, as shown in the following screenshot:
The Abbreviation option in the keyboard shortcut editor is used to quickly find the Search Everything (double Shift) dialog box. The Search Everything dialog box will be discussed in Chapter 3, The Editor.
Note that you are not allowed to change any of the predefined schemes. If you decide to tweak the existing theme, you have to copy it first. To change the editor font, select Font from the Colors & Fonts section of the IDE settings page.
Many nice color themes can be found at http://www.ideacolorthemes.org.
There is a truly great font designed especially for developers: Source Code Pro. This font family was created specifically for coding environments—it's very readable. It's available free of charge from Adobe, at GitHub https://github.com/adobe/source-code-pro.
You can download Source Code Pro for Windows, Linux, and OS X as well.
The IntelliJ IDEA plugin repository is available on the Internet at http://plugins.jetbrains.com/?idea or from the IDE itself, by going to the Plugins section in the Settings page. Going to the Plugins section in the IDE is more convenient in comparison to the Internet repository. All you have to do is find your plugin, install, and restart the IDE.
To install JetBrains' plugin, click on the Install JetBrains plugin… button. To install a third-party plugin, choose Browse repositories. In the next dialog box, you can filter the available plugins by category, or find a specific plugin just by typing its name.
To deactivate the installed plugin, uncheck the checkbox next to its name. To uninstall the plugin, use the context menu, but take note that bundled JetBrains plugins cannot be uninstalled from within the IDE, as shown here:
Some of the plugins add new languages to the IntelliJ IDEA arsenal. If you develop in a language other than Java, just filter the plugins list using the Custom Languages option. When you install the plugins, the on-the-fly analysis, hints, and refactoring will be available in your IDE. These plugins include, for example, Scala, Python, Ruby, PHP, and many others.
The next huge group of plugins is available when you filter using Framework Integration. There is a big chance you will find support for the framework you use in your project, such as AngularJS or Play, for example.
If you are new to IntelliJ IDEA, there is a plugin that is especially useful called Key promoter. It will show you a banner with the keyboard shortcut for the action you just performed using the mouse. It will help you memorize keyboard shortcuts and quickly become a keyboard ninja:
Use the Key promoter plugin available in the plugins repository to see how easy you can make the same action you just did using your mouse, by only using your keyboard!
Feel free to browse JetBrains and the third-party plugins directory. It's a real gold mine to extend the IDE functionality. Select the plugin, read the description to the right, click on Install, restart the IDE, and you're all set.
In this section, you will be presented with some configuration tips, such as sharing settings and tuning IntelliJ IDEA.
If you have your IDE set the way you like, it may be a good idea to back up all settings. Sometimes, it's good to have common settings across all team members. IntelliJ IDEA gives you the ability to archive and export all or specific settings.
To export IDE settings to a JAR archive, do the following:
Go to File | Export Settings from the main menu.
Specify the settings to export the Export Settings dialog box by selecting the checkboxes next to them. All of them are selected by default.
Specify the fully qualified name and path or click on the Browse button to choose the target file.
To import IDE settings from a JAR archive, do the following:
Go to File | Import Settings from the main menu.
Select the desired archive from the Import File Location dialog box.
Specify the settings to be imported in the Select Components to Import dialog box and click on OK.
You should be really careful with importing settings. Importing a set of settings will overwrite all your settings with the imported set. For example, if you export some live templates and reimport them during a colleague's installation, the import will overwrite all their live templates with the imported ones.
There are many nice-looking themes exported this way, available to be downloaded at http://ideacolorthemes.org. Just pick and import the JAR file and check out how beautiful your IDE will look!
Sometimes it's good to have the same configuration across all members of your team, organization, or the company. For this purpose, IntelliJ IDEA can use a server to store IDE settings and share them within your team.
To do this, first download the IntelliJ Configuration Server plugin, using the Plugins page of the Settings dialog box.
To connect to the IntelliJ Configuration Server, use your JetBrains account. If you don't have the account, you can create one on the JetBrains website using the link provided in the login dialog.
You can connect to IntelliJ Configuration Server in two ways: during the first startup or on demand.
During the first IntelliJ IDEA startup after installing the plugin, you can select the connection option for the next startup, such as Show login dialog, Login silently, or Do not login.
When the configuration server is connected, the green icon is displayed in the status bar, as shown in the following screenshot:
Otherwise, the red icon will be presented:
You can log in to the IntelliJ Configuration Server at any time using the button on the status bar.
The IntelliJ IDEA server stores almost all of the IDE and project settings except for those containing local paths. Your code style settings, keymaps, fonts, color schemes, and inspection profiles will be synced.
Take note that the IntelliJ IDEA server is a public, third-party server. It's secured by a username and password and uses SSL communication, but if you are very concerned about your privacy, you should share your settings using the export/import feature rather than the IntelliJ Configuration Server.
IDEA's Virtual Machine settings are usually very good out of the box. However, when you work on a specific huge project and decide that you want to tweak IntelliJ IDEA's own virtual machine settings, you can change that in the following locations, depending on your operating system.
On Windows, you can tweak IntelliJ IDEA's own virtual machine settings by executing the following code:
<IntelliJ IDEA installation folder>/bin/idea.exe.vmoptions
Alternatively, you can use the following code:
<IntelliJ IDEA installation folder>/bin/idea64.exe.vmoptions
On Linux and Unix systems, you can tweak IntelliJ IDEA's own virtual machine settings by executing the following code:
<IntelliJ IDEA installation folder>/bin/idea.vmoptions
Alternatively, you can use the following code:
<IntelliJ IDEA installation folder>/bin/idea64.vmoptions
On OS X, since Version 12, the file
/Applications/IntelliJ IDEA.app/Contents/bin/idea.vmoptions should be copied to the following path:
In this file, you can find, or change, Java Virtual Machine settings that IntelliJ IDEA runs on. For example, to increase the IntelliJ IDEA heap size, modify the
-Xmx setting. If you keep getting an
OutOfMemoryError message in the
PermGen space exceptions, try changing the
The file-scanning applications (such as Spotlight or Alfred on OS X, for example) can slow down the IDE a bit; think about excluding IDEA's folders from their scope.
In this chapter, we discussed what IntelliJ IDEA is, briefly presented a comparison of the available editions, and revealed the main workspace elements and how to customize them.
Install IntelliJ IDEA and try to set up your IDE the way you like it. Use the tips provided to configure the workspace like a pro. Back up your configuration or share it with others.
In the next chapter, we will create and import a project and start the actual work.