VisualStudioTutor.com Java Tutorial All Lessons

Lesson 4 of 20

IntelliJ IDEA Setup

Create and manage beginner Java projects in IntelliJ IDEA, then run and debug a small program.

Learning objectives

  • Create a Java project in IntelliJ IDEA.
  • Select the correct project JDK.
  • Understand the source folder and Java class structure.
  • Run a program from the editor.
  • Set breakpoints and inspect variables.

1. Project SDK and source folders

IntelliJ IDEA associates each Java project with a JDK. The selected JDK determines which compiler and standard-library APIs are available. A basic project normally contains a source directory such as src.

Example project structure

idea-java-demo/
└── src/
    └── TemperatureConverter.java

2. Create the project

  1. Start IntelliJ IDEA and choose New Project.
  2. Select Java as the language.
  3. Choose your installed JDK 25 (or another compatible modern JDK) as the project SDK.
  4. Create the project and locate the src folder.
  5. Right-click src, choose New → Java Class, and name it TemperatureConverter.

Example: Celsius to Fahrenheit

public class TemperatureConverter {
    public static void main(String[] args) {
        double celsius = 30.0;
        double fahrenheit = (celsius * 9.0 / 5.0) + 32.0;

        System.out.println(celsius + " C = " + fahrenheit + " F");
    }
}

The program demonstrates that the IDE is compiling and running your code correctly. The formula uses double values so decimal arithmetic is preserved.

Expected output

30.0 C = 86.0 F

3. Run and debug

Click the green run icon beside main to execute the class. To debug, click the gutter next to the Fahrenheit calculation to add a breakpoint, then choose Debug. Inspect celsius and fahrenheit.

4. Useful beginner IDE features

  • Code completion: suggests classes, methods, and variables as you type.
  • Quick fixes: offers corrections for imports and common code problems.
  • Rename refactoring: changes a symbol consistently across the project.
  • Debugger: pauses execution and shows current variable values.
  • Project view: shows files, packages, libraries, and project structure.

Common setup problems

ProblemWhy it happensHow to fix it
Project SDK shows 'No SDK'IntelliJ does not know which JDK to use.Open Project Structure and select the installed JDK.
Run icon is missingThe class has no valid main method.Check the signature: public static void main(String[] args).
Red code after changing JDKThe IDE may still be indexing.Allow indexing to finish and rebuild the project.

Mini exercise

Add a second calculation that converts Fahrenheit back to Celsius. Print both conversions and verify that the final Celsius value is close to the original.

Summary

You can now create, run, and debug Java code in IntelliJ IDEA. From Lesson 5 onward, the tutorial focuses on programming concepts rather than IDE setup.