01 / 21
>_

Using an IDE
for Java

Learn how to run, debug, and manage Java projects using professional tools like IntelliJ IDEA and Eclipse.

Java

What Is an IDE?

An Integrated Development Environment (IDE) bundles everything a programmer needs into a single application: a code editor, a compiler/build system, a debugger, and a project manager. Instead of switching between separate tools, you work inside one unified workspace.

Why Use an IDE Instead of a Text Editor?

Code Completion
The IDE suggests methods, variable names, and imports as you type, reducing typos and speeding up coding.
Error Detection
Syntax and type errors are highlighted instantly, before you even compile, with suggested quick-fixes.
One-Click Run
Compile and execute your project with a single button press instead of typing terminal commands.

Anatomy of a Java IDE

MyProject - IntelliJ IDEA File Edit View Run Debug Tools Project v src/ v main/java/ Main.java Calculator.java v lib/ Project Explorer 1 2 3 4 5 6 7 8 public class Main { public static void main(String[] args) { System.out.println("Hello"); } } int x = "text"; // error underline here Code Editor Run: Main Hello Process finished with exit code 0 Console Output Toolbar Run Debug Stop Run/Debug Controls Structure main(String[]) class Main

The Build-Run Cycle

Write .java source Compile javac Bytecode .class files Run JVM IDE automates all of this with one click You write code IDE compiles it Creates bytecode JVM executes Errors reported back in editor

Running a Java Project

1
Open the project in your IDE. The project explorer shows all source files organized in packages.
2
Locate the main class: find the file containing public static void main(String[] args): this is the program entry point.
3
Click the Run button (green triangle) or use the keyboard shortcut. IntelliJ: Shift+F10. Eclipse: Ctrl+F11.
4
Read the console output. Program output appears in the Run/Console panel at the bottom of the IDE.
5
Fix any errors. If compilation fails, the IDE highlights the error line. Click the error message to jump directly to the problematic code.

What Is Debugging?

Debugging is the process of finding and fixing errors (bugs) in your code. The IDE's debugger lets you pause execution at any line, inspect the values of variables, and step through your code one line at a time to see exactly what happens.

Breakpoint
A marker on a line of code where execution will pause. Click the gutter (left margin) to set one.
Step Over
Execute the current line and move to the next one. The method calls on that line complete without entering them.
Step Into
Enter the method being called on the current line so you can debug inside it line by line.

How to Debug a Project

1
Set a breakpoint by clicking in the left gutter next to the line number. A red dot appears.
2
Start the debugger using the Debug button (bug icon) or shortcut. IntelliJ: Shift+F9. Eclipse: F11.
3
Execution pauses at your breakpoint. The current line is highlighted in blue/green.
4
Inspect variables in the Variables panel. Hover over any variable in the editor to see its current value.
5
Step through code: use Step Over (F8) to go line-by-line, or Step Into (F7) to enter a method call.
6
Resume or stop: press Resume (F9) to continue to the next breakpoint, or Stop to end the debug session.

IntelliJ vs Eclipse

IntelliJ IDEA Eclipse
Run shortcut Shift+F10 Ctrl+F11
Debug shortcut Shift+F9 F11
Step Over F8 F6
Step Into F7 F5
Resume F9 F8
Set Breakpoint Click gutter / Ctrl+F8 Double-click gutter
Auto-import Alt+Enter Ctrl+Shift+O

Example: Running a Simple Program

public class Greeting { public static void main(String[] args) { String name = "Alice"; System.out.println("Hello, " + name); } }
1
Open Greeting.java in the IDE code editor.
2
Click Run (or press Shift+F10 in IntelliJ).
3
Console shows: Hello, Alice

Example: Finding a Bug

public class Average { public static void main(String[] args) { int a = 10, b = 20, c = 30; int avg = a + b + c / 3; // Bug! System.out.println("Average: " + avg); } }
1
Set a breakpoint on the line: int avg = ...
2
Debug. Execution pauses. Hover over avg after stepping over: you see 40 instead of 20.
3
Fix: add parentheses. Re-run and confirm avg = 20.

Example: Debugging a Loop

public class SumLoop { public static void main(String[] args) { int sum = 0; for (int i = 1; i <= 5; i++) { sum += i; // breakpoint here } System.out.println(sum); } }
Iteration i sum (after)
1st11
2nd23
3rd36
4th410
5th515

Debug Controls at a Glance

Paused at Breakpoint Step Over F8 / F6 Step Into F7 / F5 Resume F9 / F8 Execute current line, skip method internals Enter the method being called Continue running to next breakpoint Variables Panel Shows all variable values at the current pause point

Understanding Project Structure

MyProject/ src/ out/ (or bin/) Main.java Helper.java Main.class Helper.class Your source code (you edit these) Compiled bytecode (IDE generates these) compile The IDE manages this structure for you. You only need to work in the src/ folder.

Common Mistakes

✕ No Main Method
Clicking Run without a public static void main(String[] args) method. The IDE reports "Error: Main method not found."
✕ Ignoring Red Underlines
The IDE highlights errors in real time. Ignoring them and pressing Run will always fail. Read the error message first.
✕ Using print Instead of Debugger
Adding dozens of System.out.println calls to trace values. The debugger does this better without modifying your code.

IDE Workflow Summary

Task What You Do What the IDE Does
Create project New Project wizard Sets up folders, config files
Write code Type in code editor Auto-completes, highlights errors
Run Click Run / shortcut Compiles, launches JVM
Debug Set breakpoint, click Debug Pauses at breakpoint, shows variables
Fix errors Click error, edit code Jumps to error line, suggests fix
Refactor Rename / extract method Updates all references automatically

Question 1 of 5

What is the primary purpose of setting a breakpoint in an IDE?

Question 2 of 5

In IntelliJ IDEA, which keyboard shortcut runs the current project?

Question 3 of 5

What is the difference between Step Over and Step Into during debugging?

Question 4 of 5

A student clicks Run and sees "Error: Main method not found in class MyApp". What is the most likely cause?

Question 5 of 5

Which of the following is not a core component of an IDE?