Introduction to Java and IntelliJ IDEA
A Beginner-Friendly Lab Before Building Web Services
If you are seeing Java and IntelliJ for the first time, jumping directly into REST APIs or Spring Boot usually creates friction. Before building web services, you should understand how Java programs run and how an IDE helps development.
This practical is designed as a 1-hour introductory lab.
By the end of this session, students should be able to:
- Install Java and IntelliJ IDEA
- Create a Java project
- Write and run Java programs
- Take input from users
- Understand the structure of a Java application
Why are we doing this?
Web Services are built using backend technologies, and Java is one of the most widely used languages for that purpose.
Before creating APIs and web services, you need to understand:
- Classes
- Methods
- Input and Output
- Running applications
This practical creates that foundation.
Step 1 — Install Java
Java programs require the Java Development Kit (JDK).
Install Java JDK.
After installation, open Terminal / Command Prompt and verify:
java -versionExpected output:
java version "25"If this appears, Java is installed correctly.
Step 2 — Install IntelliJ IDEA
Install IntelliJ IDEA Community Edition.
Open IntelliJ after installation.
You should see:
New Project
Open
Get from Version ControlSelect:
New ProjectStep 3 — Create Your First Java Project
Configure:
Language → Java
Build System → IntelliJ
JDK → 17Click:
CreateYour project structure will appear.
Example:
MyFirstJavaProject
│
└── srcStep 4 — Create Your First Java Class
Inside src:
Right Click
New → Java ClassName:
HelloWorldIntelliJ creates:
public class HelloWorld {
}Step 5 — Write Your First Java Program
Replace the contents with:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello Students");
System.out.println(
"Welcome to Java"
);
}
}Understanding the Code
Class
public class HelloWorldEverything in Java exists inside a class.
Main Method
public static void main(String[] args)This is where execution starts.
Printing Output
System.out.println()Displays text on the screen.
Run the Program
Click:
▶ RunOutput:
Hello Students
Welcome to JavaCongratulations — your first Java application is running.
Step 6— Write Your First Interactive Java Program
Instead of printing fixed text, let the program ask for the user’s name and greet them.
Get OpenShantanu’s stories in your inbox
Join Medium for free to get updates from this writer.
Replace the code with:
import java.util.Scanner;
public class HelloWorld {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print(
"Enter your name: "
);
String name = sc.nextLine();
System.out.println(
"Hello, " + name
);
System.out.println(
"Welcome to Java!"
);
}
}Understanding the Code
Import Scanner
import java.util.Scanner;Allows Java to accept keyboard input.
Create Scanner Object
Scanner sc = new Scanner(System.in);Connects Java to user input.
Read User Input
String name = sc.nextLine();Stores the entered text.
Display Output
System.out.println(
"Hello, " + name
);Prints a personalized greeting.
Run the Program
Click:
▶ RunExample:
Enter your name: RahulHello, Rahul
Welcome to Java!Try another example:
Enter your name: PriyaHello, Priya
Welcome to Java!Mini Exercise
Modify the program to ask:
- Name
- City
Expected output:
Enter your name: Aditi
Enter your city: MumbaiHello Aditi from MumbaiThis introduces:
- Variables
- User input
- String handling
- Console output
These concepts will later be reused while building Web Services.
Reflection Questions
- What is Java?
- What is an IDE?
- Why do we use
main()? - What does
Scannerdo? - What is the difference between
print()andprintln()?
What Comes Next?
In the next practical, you can create a Web Service to act as the temperature converter.
That is the first step from introdution to console application.
