Java · Beginner level

Beginner level · Module 1: Java Setup and First Programs · Lesson 2 of 3

Working in IntelliJ IDEA

Create projects, run and debug programs, and use the IDE's code assistance instead of fighting it.

In this lesson you will

  • Create and run a Java project in IntelliJ IDEA
  • Use code completion, error highlighting and the debugger's breakpoints

Key concepts

project and modulerun configurationcode completionbreakpoint

The lesson

An IDE (integrated development environment) combines an editor, compiler, runner and debugger. IntelliJ IDEA Community Edition is a widely used IDE for Java. A new project holds a src folder for source files and is linked to the JDK you installed.

IntelliJ underlines errors as you type and suggests fixes with Alt+Enter. Typing psvm and pressing Tab creates a main method; sout creates System.out.println(). These shortcuts save time, but you should still understand the code they produce.

The debugger lets you pause a program at a breakpoint and run it one line at a time while watching variable values. It is the fastest way to find out why a program does not do what you expect.

Step by step

  1. Create a new Java project linked to your JDK.
  2. Add a class with psvm and print three lines of text.
  3. Set a breakpoint on the second line and start the debugger.
  4. Step over each line and watch the output appear.

Practice activity

Create a project called Basics, write a program that prints your name, town and course, and step through it with the debugger.

Expected result: The program runs from the green Run button, and the learner can pause it at a breakpoint and step line by line.

Check your understanding

  1. What does Alt+Enter do on an underlined error?

    Show answer

    It shows suggested quick fixes for that problem.

  2. What is a breakpoint for?

    Show answer

    It pauses the program at that line so you can inspect values and step through the code.

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.