BEST SITE FOR WEB DEVELOPERS
Java programming language. Lessons for beginners from hyperskill

Ua

IntelliJ IDEA


Theory

IntelliJ IDEA is the leading Java and Kotlin IDE by JetBrains.

In the industry, it stands out with:

  • The most advanced context-aware editor that gives you code completion hints as you type, provides fixes for errors and warnings, and lets you find anything from classes to tool windows.
  • In-depth code understanding guarantees that the IDE can instantly detect errors and provide relevant suggestions in every context.
  • Out-of-the-box experience, which means that you can start coding right from the first launch. Mission-critical tools and a wide variety of supported languages are at your fingertips – no plugin hassle involved.
  • Tools for collaborative and remote development.
IntelliJ IDEA

IntelliJ IDEA comes in two editions:

  • IntelliJ IDEA Community Edition is a free version containing more than enough features to cover the essential needs of most Java and Kotlin development.
  • IntelliJ IDEA Ultimate is a full-featured commercial version that supports various frameworks and technologies for backend and frontend development. It offers an advanced toolset to streamline your workflow. There are profiling, database tools, and an HTTP client right out of the box.

To learn more about this IDE, visit the official website.


§1. Create your first project

Let's take a closer look at how the IntelliJ IDEA works. To start with, follow the steps below to create your first app in IntelliJ IDEA.

1. Install IntelliJ IDEA Community Edition on your computer and launch it.

2. If no project is currently open in IntelliJ IDEA, click on New Project in the Projects section on the Welcome screen. Otherwise, select File | New | Project.

IntelliJ. Create your first project

3. In the New Project wizard, select New Project from the list on the left. There is also an option to create an empty project without language support.

4. Name the project (for example, Demo) and change the default location if necessary.

5. We're not going to work with version control systems in this tutorial, so leave the Create Git repository option disabled.

6. Select Java in Language, and IntelliJ in Build system.

IntelliJ. Select Java in Language, and IntelliJ in Build system

7. To develop Java applications in IntelliJ IDEA, you need the Java SDK (JDK). Your IDE will fill in the JDK field automatically. But you can change it, add the necessary JDK from your computer, or download one.

8. IntelliJ IDEA creates the project. When this process is complete, the structure of your new project is shown in the Project tool window. There are two top-level nodes:

  • Demo. This node represents your project module. The .idea directory and the file Demo.iml are used to store configuration data for your project and module, respectively. The src directory is for your source code.
  • External Libraries. This category represents all the "external" resources necessary for your development work. The standard files of your project language are placed there. You can also add other resources manually.

§2. Write your first code

Now we will write a simple piece of Java code for the Demo project.

First, let's create a class and a package.

1. In the Project tool window, right-click on the src directory, select New, and then choose Java Class.

IntelliJ. Select New, and then choose Java Class

2. In the Name field, type com.example.demo.Demo and press Enter. This is how you create a package and a class Demo inside it. Packages are used for grouping together classes that belong to the same category or provide similar functionality.

IntelliJ. This is how you create a package and a class Demo inside it

Together with the file, IntelliJ IDEA has generated some content for your class. In this case, the IDE has inserted the package statement and the class declaration.

Second, let's write the Main method and call the println() method. You can start typing the symbols, and the IDE will prompt you about possible code variants. This feature is called code completion. With its help, IntelliJ IDEA analyzes the context and suggests the choices that are reachable from the current caret position.

But in this tutorial, let's try another way. We will add the methods with Live Templates – code snippets that you can insert into your code.

1. Place the caret at the class declaration string after the opening bracket { and press Enter to start a new line.

2. Type main and select the template that inserts the main() method declaration.

IntelliJ. To start a new line IntelliJ. Select the template that inserts

As you type, IntelliJ IDEA suggests various constructs that you can use in the current context. You can see the list of available live templates using ⌘J (macOS) or Ctrl+J (Windows, Linux).

3. To call the println() method, type sout and press Enter. Inside the parentheses, type: "Hello, World!".

IntelliJ IntelliJ

Congratulations! You have written your first Java app in IntelliJ IDEA. For more information, you can always refer to the complete official tutorial.


§3. Run and debug your application

When you have a ready-to-go program, you can run it. Then, it's possible to check it for possible problems with the help of the debugger. Let's see how these tools work.

Run:

1. Click on the green triangle Run button IntelliJ IDEA run button in the gutter and select Run 'Demo.main()' in the popup. The IDE will start to compile your code.

IntelliJ

2. You will see the result in the Run window that appears.

Debug:

1. To test your program with the debugger, you must first set a breakpoint. Click on the gutter at the executable line of code where you want to set the breakpoint. Alternatively, place the caret at the line and press ⌘F8 (macOS) or Ctrl+F8 (Windows, Linux).

2. To run the debugger, click on the Bug button next to the Run one. The Debugger window will then appear with the result.

IntelliJ

§4. Customize IntelliJ IDEA

There are many settings that you can configure based on what you want or need.

1. To configure your IDE, select IntelliJ IDEA | Preferences (macOS) or File | Settings (Windows and Linux). For example, go to Appearance & Behavior | Appearance and choose different themes. In this topic, we use Darcula.

2. If you want to find something specific in the settings, use the search box as shown below.

IntelliJ

§5. Study more features in IntelliJ IDEA

You can continue exploring the IDE with helpful interactive courses right inside IntelliJ IDEA.

1. Select the Learn section on the Welcome screen and click on Start learning. The IDE will open a demo project with step-by-step instructions to guide you through all the most prominent features and tools that IntelliJ IDEA offers.

IntelliJ Interactive courses

§6. Conclusion

To summarize this general introduction to IntelliJ IDEA, we can say that this IDE suits you perfectly if you:

  • Want to start coding just several minutes after installation and access all the crucial features right away.
  • Enjoy working in a powerful, ergonomic editor that can predict what code you need to write in a specific context and offers fixes to possible problems on the go.
  • Like to customize the IDE to your needs and taste.
  • Appreciate fast navigation and instant search.

We hope you try out IntelliJ IDEA to discover more of its features. For more detailed information, you can refer to IntelliJ IDEA Help.

You can also view Lesson on hyperskill.org.


Practical tasks and answers

Tasks and answer options are given. The correct option is highlighted in blue color.

№1. Context actions

Question: IntelliJ IDEA can do something with context near the cursor. How can you use this feature in Windows OS?

Select one option from the list:

  • Using Alt+Enter keystroke ✔
  • Creating a new project
  • Going to File | Settings
  • Using the Change to action
  • Creating a new file

Explanation. You can use the feature of IntelliJ IDEA that works with context near the cursor in Windows OS by using the Alt+Enter keystroke.


№2. Settings

Question: Where can you customize the IntelliJ IDEA settings?

Select one option from the list:

  • Help
  • IntelliJ IDEA | Preferences (macOS) or File | Settings (Windows and Linux) ✔
  • View | Tool Windows
  • File | Project Structure

Explanation. You can customize the IntelliJ IDEA settings by going to IntelliJ IDEA | Preferences if you are using macOS or File | Settings if you are using Windows or Linux.


№3. Theme

Question: Suppose, we have a project open in IntelliJ IDEA. Where do you go to change the theme to Darcula?

Select one option from the list:

  • Help
  • Tools
  • File | Project Structure
  • File | Settings for Windows and Linux, or IntelliJ IDEA | Preferences for macOS ✔
  • View | Tool Windows

Explanation. To change the theme to Darcula in IntelliJ IDEA when a project is open, you need to go to File | Settings if you are using Windows or Linux, or IntelliJ IDEA | Preferences if you are using macOS. Then, in the left-hand pane, select Appearance & Behavior | Appearance and choose Darcula from the dropdown menu next to Theme.


№4. Debug session

Question: What should you do before running a debug session?

Select one option from the list:

  • Run your program
  • Set a breakpoint ✔
  • Check the spelling

Explanation. Before running a debug session, you should set a breakpoint.


№5. Start the program

Question: What points do you need to pay attention to in order for the program to run?

Select one or more options from the list:

  • choose the right color scheme
  • check if a program contains the main method ✔
  • make sure the source code is in the src directory ✔
  • select a JDK ✔

Explanation. In order for a program to run, you need to check if the program contains the main method and select a JDK. Additionally, you need to make sure that the source code is in the src directory. Choosing the right color scheme is not necessary for running a program.


№6. The location of source code

Question: When we create a Java project in IntelliJ IDEA, where is the source code located?

Select one option from the list:

  • In the out directory or its subdirectories
  • In the root project directory or its subdirectories
  • In the src directory or its subdirectories ✔
  • In the .idea directory or its subdirectories

Explanation. When we create a Java project in IntelliJ IDEA, the source code is located in the src directory or its subdirectories.


№7. Old is Gold

Question: What was the original name of Java?

Select one option from the list:

  • Javax
  • Oak ✔
  • Train

Explanation. The original name of Java was Oak.


№8. Live Templates

Question: What are Live Templates?

Select one option from the list:

  • Roadmaps for live testing
  • Code snippets that you can insert into your code ✔
  • Ready-made Java projects for beginners

Explanation. Live Templates are code snippets that you can insert into your code.


№9. Structure

Question: Once your project is created, where can you see its structure?

Select one option from the list:

  • In the editor
  • In the Run tool window
  • In the Project tool window ✔
  • In IntelliJ IDEA | Preferences (macOS) or File | Settings (Windows and Linux)

Explanation. Once your project is created, you can see its structure in the Project tool window.


№10. What is IntelliJ IDEA?

Question: What is IntelliJ IDEA?

Select one option from the list:

  • A mobile game written in Java
  • The leading Java and Kotlin IDE by JetBrains ✔
  • An online compiler for Java, JavaScript, and Kotlin
  • A mobile app for Java and other JVM languages development

Explanation. IntelliJ IDEA is the leading Java and Kotlin IDE by JetBrains.


№11. Project content

Question: What are the two top-level nodes every IntelliJ IDEA project consists of?

Select one or more options from the list:

  • Internal libraries
  • External libraries ✔
  • Helloword
  • Project ✔

Explanation. The two top-level nodes every IntelliJ IDEA project consists of are Project and External Libraries.

  • The Project node contains all the files and folders that belong to the project. This includes the source code, resources, and compiled classes.
  • The External Libraries node contains all the libraries that are used by the project. These libraries can be either third-party libraries or libraries that are created by the project team.

What is IntelliJ IDEA? What is it for? Where is it used? Who is the author and developer?

IntelliJ IDEA is an integrated development environment (IDE) for Java and other JVM languages. It is used for developing software applications, particularly in Java and Kotlin. IntelliJ IDEA provides a variety of features such as code completion, syntax highlighting, refactoring, and debugging tools to help developers write, test, and debug their code more efficiently.

IntelliJ IDEA is developed and maintained by JetBrains, a software development company based in Prague, Czech Republic. The company was founded in 2000 by Sergey Dmitriev, and its primary focus is on creating productivity tools for software developers.

IntelliJ IDEA is used by developers worldwide, including individuals, small businesses, and large corporations. It is popular among Java developers due to its advanced features, ease of use, and integration with other JetBrains tools such as Kotlin and TeamCity.