JDK & IntelliJ Install
Before you write a single line of Java in IntelliJ, two things need to be on your machine: the JDK (which runs Java) and IntelliJ IDEA itself. This lesson gets both installed cleanly.
Step 1 β Install the JDK
The Java Development Kit (JDK) is what actually compiles and runs your Java code. IntelliJ is just the editor β it needs the JDK to do its job. The recommended version for learning is JDK 21 (the current long-term support release).
Download JDK 21
Go to adoptium.net (Eclipse Temurin). Click "Latest LTS release" β this gives you JDK 21. Download the installer for your OS (Windows .msi, macOS .pkg, Linux .deb/.rpm).
Run the installer
On Windows and macOS: double-click the installer and follow defaults. On Linux: sudo apt install temurin-21-jdk (after adding the Adoptium repo) or use your package manager.
Verify the install
Open a terminal and run: java -version. You should see openjdk version "21...". Also run javac -version β this confirms the compiler is installed.
Step 2 β Install IntelliJ IDEA
Download IntelliJ IDEA Community
Go to jetbrains.com/idea/download. Choose Community Edition β it's free, open-source, and has everything you need for Java development. The Ultimate edition (paid) adds web frameworks and databases, but you don't need it yet.
Install it
Windows: Run the .exe installer. Check "Add to PATH" and "Create Desktop Shortcut". macOS: Drag the .app to Applications. Linux: Extract the tar.gz to /opt/, then run bin/idea.sh. Or install via the JetBrains Toolbox App (recommended β handles updates automatically).
First launch
On first launch IntelliJ asks about UI theme and settings import. Choose Darcula (dark) or Light. Skip the import β start fresh. You'll end up at the Welcome Screen.
The free JetBrains Toolbox app manages all JetBrains tools in one place. It handles updates automatically, lets you install/uninstall versions, and keeps your configuration across reinstalls. Download it from jetbrains.com/toolbox-app.
If the JDK verification failed above, don't worry. IntelliJ can download and configure a JDK itself when you create your first project. In the new project wizard, click "Add SDK" β "Download JDK" and select version 21.
Your First Project
IntelliJ organises work into projects. A project is a folder with all your Java files, plus configuration telling IntelliJ how to build and run them. Creating one correctly takes two minutes.
Open the Welcome Screen
Launch IntelliJ. The Welcome Screen shows recent projects and a big "New Project" button. If you already have a project open, go to File β New Project.
New Project settings
Select New Project from the left sidebar. Set: Name = HelloWorld, Location = wherever you keep code, Language = Java, Build system = IntelliJ (simplest for now), JDK = your JDK 21. Leave "Add sample code" checked for your first project.
Understand the project structure
IntelliJ creates this layout: HelloWorld/ contains src/ (your Java source files) and HelloWorld.iml (IntelliJ module config β don't edit this manually).
Run the sample code
IntelliJ creates a Main.java with a Hello World. Click the green βΆ button in the gutter next to main, or press ShiftF10. The output appears in the Run panel at the bottom.
Opening your existing Task Manager project
If you already have a Java project from the beginner course, you don't need to create a new one. Just go to File β Open and navigate to the folder containing your .java files. IntelliJ will import it and you'll need to set the JDK: File β Project Structure β Project β SDK β select your JDK 21.
Everything you write goes inside src/. The .idea/ folder and .iml files are IntelliJ's internal configuration β never edit them by hand. If you're using Git, add .idea/ to your .gitignore (except .idea/vcs.xml if you want to share VCS settings).
Main.java file shows red underlines everywhere even though the code looks right. What's the most likely cause?The Interface
IntelliJ has a lot of panels. Knowing what each one is for β and how to summon the ones you need β means you never waste time hunting around the UI.
The panels you'll use constantly
| Panel | What it's for | How to open |
|---|---|---|
| Project | File tree β navigate between classes | Alt1 or click the π icon on the left |
| Editor | Where you write code β always visible | Double-click any file in Project panel |
| Run | Program output (System.out.println) | Alt4 or run your program |
| Debug | Breakpoints, variable inspection | Alt5 or run in debug mode |
| Terminal | Built-in terminal β run git commands | AltF12 |
| Problems | All errors and warnings in the project | Alt6 |
| Git | Commit, push, branch, history | Alt9 |
| Structure | Methods and fields in the current class | Alt7 |
The gutter
The gutter is the thin strip to the left of your code β where line numbers live. It does a lot: green βΆ run buttons appear next to main methods, red dots mark breakpoints, green/red change indicators from Git appear, and yellow lightbulbs signal available quick-fixes. You'll interact with it constantly.
The status bar
The very bottom of the window. Shows current line/column, encoding, branch name, background task progress, and the current inspection profile. If IntelliJ is doing something slow (indexing, building) it shows progress here.
The single most powerful shortcut in IntelliJ: press Shift twice to open "Search Everywhere". Type any file name, class name, method, setting, or action. It finds everything. If you can't remember a shortcut, just Search Everywhere for the action name.
Essential Shortcuts
Learning shortcuts is the single biggest productivity multiplier in IntelliJ. Developers who use the keyboard instead of the mouse write code measurably faster. These are the ones you'll use every single day.
Navigation shortcuts
Editing shortcuts
Run & refactor shortcuts
On macOS, every shortcut that uses Ctrl on Windows/Linux uses β Cmd instead. So CtrlB becomes βB. The exception: Alt stays as β₯ Option. IntelliJ shows OS-correct shortcuts in all its menus.
addTask() method is called. Which shortcut do you use while your cursor is on the method name?Code Completion
IntelliJ's code completion is one of the best in any IDE. It knows Java's entire standard library, your own classes, and it suggests completions as you type β often finishing entire statements for you.
Basic completion
As you type, IntelliJ shows a dropdown of completions automatically. Press Enter or Tab to accept the highlighted suggestion. Tab replaces the word under the cursor; Enter inserts without replacing.
If the dropdown closed, press CtrlSpace to bring it back.
Live templates β type a shortcut, get a block
Live templates expand abbreviations into full code blocks. These will save you enormous amounts of typing:
| Type this | Then press Tab | Get this |
|---|---|---|
| sout | Tab | System.out.println() |
| soutv | Tab | System.out.println("variableName = " + variableName) |
| fori | Tab | A complete for (int i = 0; i < ; i++) loop |
| iter | Tab | A complete for-each loop |
| psvm | Tab | public static void main(String[] args) {} |
| ifn | Tab | if (var == null) {} |
| inn | Tab | if (var != null) {} |
| try | Tab | Complete try-catch block |
Postfix completion β type after the expression
Postfix completions let you type a suffix after an expression and IntelliJ wraps it for you. Much faster than going back to the start of a line:
| Type | Result |
|---|---|
tasks.for + Tab | Wraps in a for-each loop over tasks |
condition.if + Tab | Wraps in an if (condition) {} block |
value.var + Tab | Introduces a variable: var x = value |
expr.not + Tab | Wraps in negation: !expr |
list.size.sout + Tab | System.out.println(list.size()) |
Generate code with Alt+Insert
Place your cursor inside a class and press AltInsert. IntelliJ shows a menu to generate: Constructor, Getter, Setter, equals/hashCode, toString, overridden methods. This writes boilerplate you'd otherwise type by hand β and gets it right every time.
sout inside a method body and press Tab. What happens?Refactoring Tools
Refactoring means restructuring code without changing what it does β cleaning it up, making it clearer, or reorganising it safely. IntelliJ's refactoring tools do it automatically across your entire project.
Rename β the most used refactoring
Press ShiftF6 on any variable, method, class, or field. IntelliJ renames it everywhere in the entire project simultaneously β including all usages, string references, and comments. It also checks for naming conflicts and warns you.
Never do a manual find-and-replace for renaming. One missed occurrence silently breaks your code. Always use Rename refactoring.
Extract Variable β CtrlAltV
Select any expression and press the shortcut. IntelliJ creates a new local variable holding that expression and replaces it (and any duplicates) throughout the method. Turns messy nested expressions into readable named variables.
Extract Method β CtrlAltM
Select a block of code and press the shortcut. IntelliJ creates a new method with the right parameters and return type, moves the code into it, and replaces the original block with a method call. This is how you break up long methods into smaller, named ones.
Inline β the opposite of extract
On a variable or method, press CtrlAltN to inline it β replace every usage with the actual value/code and remove the variable or method. Useful when a variable is only used once and the name doesn't add clarity.
Change Signature
Right-click a method β Refactor β Change Signature (or CtrlF6). Add, remove, or rename parameters and IntelliJ updates every call site across the project.
Whenever IntelliJ shows a yellow lightbulb or a red underline, press AltEnter. It shows every available quick-fix and intention action for the problem at your cursor β import a missing class, flip a condition, convert a loop to streams, add a null check, implement interface methods. IntelliJ almost always knows what you probably want.
Refactor your Task Manager
Open your Task Manager project and try each of these:
- Rename
addTasktocreateTaskusing ShiftF6 β verify every call site updated - Find a long expression in your code and extract it to a named variable with CtrlAltV
- Select a block of 5+ lines and extract it to a method with CtrlAltM
- Press AltInsert inside the Task class and generate a
toString()method
taskList to tasks across your entire project. What's the right approach?Run Configurations
A Run Configuration tells IntelliJ exactly how to start your program: which class to run, what arguments to pass, which environment variables to set. Understanding them means you can run your program any way you need.
The simplest way to run
Click the green βΆ in the gutter next to your main method, or press ShiftF10. IntelliJ automatically creates a run configuration the first time and reuses it after that. The current run configuration is shown in the toolbar dropdown at the top right.
Creating a custom run configuration
Go to Run β Edit Configurations (or click the dropdown in the toolbar and choose "Edit Configurations"). Click + β Application.
Name
Give it a descriptive name like "Task Manager - Run" or "Task Manager - with test file"
Main class
Click the folder icon and choose your main class (the one with public static void main). Or type the fully-qualified name: com.example.Main
Program arguments
If your main(String[] args) reads from args, put those arguments here. Example: --verbose debug
Environment variables
Add key=value pairs here instead of hardcoding secrets in your source. Example: DB_PASSWORD=secret123 (never put secrets in code!)
Working directory
The directory your program runs from β affects where relative file paths resolve. Usually the project root or module root.
You can have several run configurations for the same project. A "Normal run", a "Debug run with verbose logging", and a "Run with test data" are all useful to have. Switch between them from the toolbar dropdown. Press ShiftAltF10 to pick from a list.
Reading input from a file instead of typing it
If your program reads from System.in (keyboard) and you're tired of typing the same input every test run, redirect from a file: in Run Configurations β Redirect input from β browse to a test-input.txt file. Every run reads from that file automatically. Huge timesaver for interactive programs.
System.in and you want to test the same sequence of commands repeatedly without retyping them. What's the best IntelliJ approach?The Debugger
The debugger is the most powerful tool for understanding what your code is actually doing. Instead of guessing, you pause the program at any line and inspect the exact value of every variable. This lesson will change how you fix bugs forever.
Breakpoints
A breakpoint pauses the program when execution reaches that line. Click in the gutter to the left of a line number β a red dot appears. Run the program with ShiftF9 (Debug, not Run). The program stops at your breakpoint and the Debug panel opens.
Stepping through code
Watches and Evaluate
In the Debug panel, you can add Watches β expressions that IntelliJ evaluates and displays continuously as you step through code. Right-click any variable in the Variables panel β "Add to Watches". Or press AltF8 to open Evaluate Expression and type any valid Java expression to see its value immediately β you can even call methods.
Conditional breakpoints
Right-click a breakpoint dot β Condition. Enter a boolean expression. The program only pauses when that condition is true. Essential for breakpoints inside loops β instead of hitting it 1000 times, only break when i == 500 or task.getId() == 3.
Beginners scatter println statements everywhere to trace execution. The debugger does everything println does β and more. It shows every variable simultaneously, lets you step line by line, and doesn't require recompiling after each guess. Once you learn the debugger you'll never go back to printf debugging.
Debug your Task Manager
- Set a breakpoint at the start of your
addTask()method - Run in Debug mode and trigger an add operation
- When the program pauses, inspect the
taskslist in the Variables panel - Use F8 to step through the method line by line β watch variables update in real time
- Set a conditional breakpoint that only triggers when
title.length() > 10
Git Integration
IntelliJ has first-class Git support built in. You can stage, commit, push, pull, branch, and resolve merge conflicts without leaving the IDE. The terminal is still there when you need it, but the GUI is often faster.
Enable VCS for your project
If your project doesn't have Git yet: Git β Initialize Repository. If you're cloning from GitHub: File β New β Project from Version Control and paste the URL.
The Git panel
Press Alt9 to open the Git panel. It shows three tabs: Local Changes (modified/untracked files), Log (full commit history with graph), and Console (raw git output).
Committing
Press CtrlK to open the Commit dialog. All changed files are listed β check the ones you want to include (staging). Write a commit message. Click Commit (or Commit and Push to do both at once).
Resolving merge conflicts in IntelliJ
When a pull causes a conflict, IntelliJ highlights the conflicting files in red. Click Resolve in the notification, or open the file and click the purple "Merge" banner at the top. IntelliJ shows a three-panel diff: your version on the left, the incoming version on the right, and the merged result in the centre. Click the arrows (β or β) to accept each change.
Modified lines show a blue bar in the gutter. New lines show a green bar. Click any marker to see a popup with the diff and options to revert just that chunk. You never have to open a full diff view for small changes.
Settings & Plugins
IntelliJ is highly configurable. The right settings and a few key plugins make it significantly more comfortable to work in. These are the ones that experienced Java developers actually use.
Key settings to configure first
Open Settings with CtrlAltS (macOS: β,).
| Setting location | What to change |
|---|---|
| Editor β General β Auto Import | Turn on "Add unambiguous imports on the fly" and "Optimize imports on the fly" β IntelliJ adds and removes imports automatically as you type |
| Editor β Code Style β Java | Set tab size and indent to 4. Set the right margin (column guide) to 120 or 150. This shows a vertical line at that column so lines don't get too long. |
| Editor β Inspections | These control what IntelliJ warns about. The defaults are good β learn to read the warnings rather than disabling them. |
| Keymap | If you use VS Code or Eclipse, you can switch to their keymap. Or leave on IntelliJ's default (recommended β most tutorials use it). |
| Appearance & Behavior β Appearance β Theme | Darcula (dark) or IntelliJ Light. Many developers use the One Dark Vivid plugin theme. |
| Build, Execution β Compiler | Turn on "Build project automatically" if you want IntelliJ to compile as you type. Combined with "compiler.automake.allow.when.app.running" it recompiles in the background. |
Plugins worth installing
Open Settings β Plugins β Marketplace to search and install.
| Plugin | What it does |
|---|---|
| .ignore | Helps create and manage .gitignore files with templates for every project type |
| Rainbow Brackets | Colours matching bracket pairs β makes nested code much easier to read |
| String Manipulation | Lots of string operations (camelCase, snake_case, sort lines, escape/unescape) via right-click menu |
| SonarLint | Runs code quality and security analysis as you type β teaches you to write better Java |
| Lombok | Required if you use the Lombok library β generates getters/setters/constructors at compile time |
| GitToolBox | Shows inline git blame annotations next to each line as you read code |
Each plugin slows IntelliJ's startup and indexing slightly. Start with a few essentials. If IntelliJ feels slow, go to Help β Diagnostic Tools β Activity Monitor to see which plugins are consuming CPU. Disable ones you don't actively use.
Capstone: Pro Workflow
Pull everything together into the workflow professional Java developers actually use. This is what a productive day in IntelliJ looks like β using the keyboard, the debugger, and Git without breaking flow.
The complete feature workflow
Here's the sequence a senior developer follows when building a new feature. By the end of this course, this should feel natural to you:
Pull latest changes
CtrlT to pull. Check the Git Log panel to see what changed. Switch to a new branch from the branch picker in the bottom status bar.
Navigate to the right code
Double-tap Shift to search for the class or method you need. Press CtrlB to jump to declarations. Use CtrlE to switch between recently opened files.
Write code with completion
Use live templates (sout, fori, iter). Let IntelliJ auto-complete method names. Press AltEnter on any warning to see quick-fixes. Press AltInsert to generate boilerplate.
Format as you go
CtrlAltL to format any time. CtrlAltO to clean up imports. The code stays readable throughout β not just before commits.
Debug when something's wrong
Set a breakpoint at the suspect code. Press ShiftF9. Step through with F8/F7. Watch variables in the Debug panel. Don't guess β verify.
Refactor to clean up
Once it works: ShiftF6 to rename anything unclear. CtrlAltM to extract long methods. CtrlAltV to name complex expressions. Make it readable.
Commit with a good message
CtrlK. Stage only the relevant files. Write a clear message: what changed and why. Commit. Then CtrlShiftK to push.
If you learn nothing else from this course, learn these seven: ShiftShift (find anything), AltEnter (quick-fix), CtrlB (go to definition), ShiftF6 (rename), CtrlAltL (format), ShiftF9 (debug), CtrlK (commit). Those seven will make you dramatically faster within a week.
A full feature cycle in IntelliJ
Using only IntelliJ (no terminal except the built-in one), complete this workflow with your Task Manager:
- Create a new branch called
feature/task-statisticsfrom the Git panel - Add a
getStatistics()method that returns total tasks, completed count, and completion percentage β use AltInsert to help generate the structure - Set a breakpoint inside the method and run in debug mode β verify the values are correct by inspecting variables
- Rename the method to
getSummary()using ShiftF6 - Format the file with CtrlAltL
- Commit with a meaningful message using CtrlK
- Push to GitHub using CtrlShiftK