Sitemap

Introduction to Java and IntelliJ IDEA

A Beginner-Friendly Lab Before Building Web Services

--

Press enter or click to view image in full size
Photo by Luca Bravo on Unsplash

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 -version

Expected 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 Control

Select:

New Project

Step 3 — Create Your First Java Project

Configure:

Language → Java
Build System → IntelliJ
JDK → 17

Click:

Create

Your project structure will appear.

Example:

MyFirstJavaProject
│
└── src

Step 4 — Create Your First Java Class

Inside src:

Right Click

New → Java Class

Name:

HelloWorld

IntelliJ 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 HelloWorld

Everything 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:

▶ Run

Output:

Hello Students
Welcome to Java

Congratulations — 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:

▶ Run

Example:

Enter your name: Rahul
Hello, Rahul
Welcome to Java!

Try another example:

Enter your name: Priya
Hello, Priya
Welcome to Java!

Mini Exercise

Modify the program to ask:

  1. Name
  2. City

Expected output:

Enter your name: Aditi
Enter your city: Mumbai
Hello Aditi from Mumbai

This introduces:

  • Variables
  • User input
  • String handling
  • Console output

These concepts will later be reused while building Web Services.

Reflection Questions

  1. What is Java?
  2. What is an IDE?
  3. Why do we use main()?
  4. What does Scanner do?
  5. What is the difference between print() and println()?

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.

--

--