IntelliJ IDEA 2016.2 Help

Quick Start Guide

If you have successfully installed Intellij IDEA on your computer, it's time to run it for the first time. You will see the Welcome Screen which gives you main entry points to the IDE. Here you can create a new project, open an existing one, or check out the project from version control.

ij_qsg_01_welcome_screen

Run Your First Java Application

Let's create a simple Java Hello World project. Click Create new project . The New Project Wizard opens.

ij_qsg_02_project_wizard

The main thing you should pay attention to is the Project SDK. SDK (Software Development Kit) is a set of software development tools that lets you develop applications. IntelliJ IDEA does not include an SDK, so If you have none, download and install it. Since we make a Java project, we need a Java SDK (JDK). After installation, click New and point to the installation folder of the JDK.

ij_qsg_03_setup_sdk

In the New Project Wizard, you can choose technologies your project will support, but as you're making a plain Java Application, select none of them and just click Next. Then IDE offers you to create project from a template. We don't need this now, so click Next .

ij_qsg_04_templates

Specify the name and location of the project. Click Finish .

ij_qsg_05_projectname

You have src folder inside your project. This is the folder for your source code. Right click on this folder, then choose New | Java Class .

ij_qsg_06_new_class

Enter the name of this class, say, quickstart.HelloWorld, and click Finish .

ij_qsg_07_class_name

Now the new class opens in the editor. Notice, that HelloWorld class is created in quickstart package. HelloWorld program text is a known one.

package quickstart; public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }

Put it inside the class.

ij_qsg_08_hello_world

Every time you run an application, you need to have a configuration, which this process is based on. For creating a run configuration click Run | Edit configurations' Then click add.png and choose Application .

ij_qsg_09_new_run_config

Here you can specify the main class and program arguments. Since we have a simple application, we need to point the Main class only. Put quickstart.HelloWorld into the Main class text field. Print something in Name field, for example, HelloWorldConfig . Run configuration is ready.

ij_qsg_10_run_config

Now you can immediately run your application and make sure all works properly. Choose Run | Run 'HelloWorldConfig' from the main menu. Get a result!

ij_qsg_11_result

For debugging your application, choose Run | Debug. You should also have Run Configuration for this. To learn more, see Run/Debug Configuration: Application.

Look Around

Let's have a closer look on the main window of IntelliJ IDEA. There are several logical areas:

ij_qsg_35_layout
  1. Menus and toolbars contain commands that affect the entire project or large portions of it. Additionally, context-sensitive pop-up menus let you perform the commands, which are specific to a part of a project, like source file, class, etc.
  2. Navigation bar helps navigate through the project and open files for editing.
  3. The status bar indicates the status of your project, the entire IDE, and shows various warning and information messages.
  4. The editor where you create and modify the code.
  5. Tool windows perform different functions: help you explore and navigate through the projects and file structures, view search and inspection results, run, debug and test applications, work in interactive consoles, and more.
  6. Left gutter —the vertical stripe which shows the breakpoints you have, and provides a convenient way to navigate through the code hierarchy like going to definition/declaration. It also shows line numbers and per-line VCS history.
  7. Right gutter —this stripe constantly monitors the quality of your code and always shows the results of its code analysis: errors, warnings, etc. The square in the top right-hand corner shows the overall status of code analysis for the whole file.

Smart Coding

IntelliJ IDEA has a powerful editor and always helps you creating error-free applications. There are many smart features in IDE, let’s have a look on the most important ones.

Code completion

Code completion takes into account the current context and saves your time. There are two main types of code completion in IntelliJ IDEA: basic (Ctrl+Space) and smart (Ctrl+Shift+Space). Basic completion works as you type and completes any name instantly. Smart completion analyzes the context you’re currently working in and offers more accurate suggestions based on that analysis. It filters the list of functions and variables to match the expression type.

ij_qsg_36_completion

Intention actions

When a possible problem is suspected, IntelliJ IDEA suggests a solution, and in certain cases can implement this solution (properly assign variables, create missing references and more). Besides syntax problems, IntelliJ IDEA recognizes code constructs that can be optimized or improved, and suggests appropriate intention actions, denoted with the special icons. If you want to know exactly what IDE suggests you in the current situation, click the light bulb, or press Alt+Enter.

ij_qsg_37_intention

Refactoring

IntelliJ IDEA provides a huge set of automated code refactorings from mere renaming to such complicated things as changing a method signature.

ij_qsg_38_refactoring

Project Configuration in a Nutshell

In Intellij IDEA all exists in the context of a Project, the highest level of organization in the IDE. To specify the configuration of your project choose File | Project Structure

ij_qsg_12_project_structure

Here you can see several items in Project Settings. Let's have a look at them.

Project . Strictly speaking, here are the settings referring to the project generally, where you can configure the name, SDK, language level, and the compiler output path.

Modules . Every project consists of modules. Module is a discrete unit of functionality that can be compiled, run, debugged and tested independently. Modules contain everything that is required for their specific tasks: source code, build scripts, unit tests, deployment descriptors, and documentation. A module can be a dependency for another module in the project.

ij_qsg_13_modules

Libraries . It is one of the module dependency types in Intellij IDEA, an archive of compiled code that a module can depend on. A Java library, for example, can include class files, archives and directories with class files as well as directories with Java native libraries (.dll, .so or .jnilib).

Facets . Each module can have a number of facets. Facets are required by the IDE to to provide framework-specific coding assistance, e.g. Web, Spring, Persistence. Mostly, facets are detected automatically by IDE, but here you can configure them manually.

Artifacts . An artifact is the output you want IntelliJ IDEA to generate for your project. It may be a Java archive (JAR), Web application archive (WAR), an enterprise archive (EAR), etc. When you use a build tool, the artifacts are configured automatically, otherwise configure them manually in this section

ij_qsg_14_artifacts

For more information about project structure, read Project Structure Dialog or watch "Project Structure and Configuration" video tutorials.

Build Your Project

If your project doesn't use a build tool, use Build menu with the following commands:

  • Compile: Compiles files in the selected scope, whether they've changed or not.
  • Make: Compiles files if they have changed.
  • Rebuild Project: Forces a recompile of the entire project.
You can also look at the 'Make, compile and rebuild ' tutorial and see Compilation Types .
ij_qsg_14_make_compile

IntelliJ IDEA supports Ant , Maven and Gradle . You can create a new project either by using the Project Wizard and choosing a corresponding build tool, or by importing an existing project from source and choosing the corresponding build file to import from.

ij_qsg_15_create_wbt

If your project uses a build tool, you can also run the tasks of your build tool just from Intellij IDEA. Build menu still works for that kind of projects.

IntelliJ IDEA provides a tool window for a build tool where you can manage specific operations. To open it go to View | Tool Windows | Build Tool Name .

ij_qsg_16_bt_window_menu

In this window you can also control behavior of the build, run build tasks and add tasks to run configuration as well.

For more information about supported build tools, you can see web help pages about Ant , Gradle or Maven or take a look at "Building on Ant, Gradle and Maven" video tutorial.

Run and Debug Your Application

Run/Debug configuration describes what happens when you click the Run or Debug button in the Toolbar or from Run menu. You can create several configurations and use the particular one you need by choosing from the dropdown. To edit run configuration click Run | Edit configurations'

To learn different types of run configurations, please look at the Run/Debug Configurations . See also Run/Debug Configuration basics .

Run and Debug Your Application

Make sure that appropriate test framework is specified in the dependencies of your module.

ij_qsg_18_test_framework

For running all tests in your application, right-click the test folder and then click Run 'All Tests' .

ij_qsg_19_run_tests

You can run particular test by pressing Ctrl+Shift+F10 on it. It is also based on run configuration.

Don't forget to watch Testing video tutorials and read Testing web help page .

Deploy Your Application to an Application Server

Before you deploy an application to an application server, make sure to configure this application server in File | Settings | Build, Execution, Deployment | Application Servers

ij_qsg_20_appserver_specified

Once you have your application server configured, create a corresponding Run/Debug configuration, and specify your application server:

ij_qsg_21_run_coinfig_for_as

Also, in the Deployment tab specify the actual artifacts to be deployed:

ij_qsg_22_artifacts_deployment

Find more comprehensive tutorial about deploying a Java EE application to an application server at Developing a Java EE Application .

Customize Everything

Customize IDE appearance in File | Settings | Appearance & Behaviour | Appearance. Intellij IDEA provides light and dark appearance themes. There can be several light ones, depending on your OS, and a dark one called Darcula .

ij_qsg_24_darcula

Customize the behaviour of the text editor in File | Settings | Editor .

In File | Settings | Editor | Colors and fonts , you can choose any color scheme for the Editor, modify them and save them as your own.

ij_qsg_25_editor_colors

For configuring styles, go to File | Settings | Editor | Code Style. IntelliJ IDEA automatically applies a code style you've configured.

ij_qsg_26_code_styles

There are lots of shortcuts you can use in the text editor. Begin with checking the shortcuts you cannot miss . Also, download a reference card with most frequently used shortcuts for the various platforms: Win/Linux , MacOS .

For choosing from several keymaps Intellij IDEA offers you, go to File | Settings | Keymap. You can also assign your own shortcut to any action.

ij_qsg_27_keymaps

Some customizations can be shared with your team via VCS.

Finding Your Way Around

If you've just forgotten a shortcut, use Find Action (Ctrl+Shift+A) and look for action by name.

ij_qsg_28_find_action

Finally, if you want to find something, but you have no idea where to search, use Search everywhere function by pressing Shift twice.

ij_qsg_29_search_everywhere

Generally, if you want to find something in settings, use the search bar in the Settings/Preferences dialog .

Try start typing anywhere with trees or lists and find out that speed search is working in many places.

ij_qsg_30_speed_search

Version Control Integration

IntelliJ IDEA supports Git, CVS, Mercurial, Perforce and others. Having decided which one to use, specify its settings in File | Settings | Version Control. It's possible to add your current project or an existing project as a new VCS root.

ij_qsg_31_vcs_settings

Besides general VCS settings, here you can configure all that corresponds to the particular VCS you are going to use.

ij_qsg_31_git_settings

IDE lets you add, delete, commit, revert, manage branches, see history, push, pull and do many other things. Some operations are available in Version control tool window called by VCS | Show Changes View .

ij_qsg_32_vcs_tool_window

Others can be called from corresponding point of VCS menu.

ij_qsg_33_git

To learn more about VCS see Version Control with IntelliJ IDEA and watch Version Control video tutorials .

Migration from Eclipse or NetBeans

We try to do our best to make migration from other IDE's as painless as possible. For those who migrate from Eclipse, there is a detailed migration guide . For those who migrate from NetBeans it is useful to read IntelliJ IDEA for NetBeans Users . Remember that you can keep previous IDE keymap, and also have a look at Importing projects from other IDE video tutorials.

What's Next?

When you complete this guide, have fun watching Tips and tricks video from Hadi Hariri. Feel free to share your feedback in our discussion forum and issue tracker. We wish you a good luck with finding your way through Intellij IDEA!

See Also

Getting Started:

Language and Framework-Specific Guidelines:

Last modified: 23 November 2016