Skip to content

Latest commit

 

History

History
149 lines (102 loc) · 2.3 KB

File metadata and controls

149 lines (102 loc) · 2.3 KB

Module 1: Java Setup & Basic Syntax

Objective

Set up the Java development environment and understand the basic structure and syntax of a Java program.


1. Java Installation

Step 1: Install JDK

  • Download JDK (Java 17 or later – LTS recommended)
  • Install using default settings

Step 2: Verify Installation

Open terminal / command prompt and run:

java -version
javac -version

If the version is displayed, Java is installed correctly.

2. Environment Variables (Windows)

Set the following variables:

  • JAVA_HOME
    Example:

    C:\Program Files\Java\jdk-17
    

  • Add to PATH:

%JAVA_HOME%\bin

Restart the system after setup.


3. Java IDE Setup

You can use any one of the following:

  • IntelliJ IDEA (Recommended)
  • Eclipse
  • VS Code (with Java Extension Pack)

Create a new Java project after IDE installation.


4. First Java Program

public class Main {
  public static void main(String[] args) {
      System.out.println("Hello, Java");
  }
}

Explanation:-
  • class : Blueprint of the program

  • main() : Entry point of execution

  • System.out.println() : Prints output to console


5. Basic Java Syntax Rules

  • Java is case-sensitive

  • Every statement ends with ;

  • Code blocks use { }

  • File name should match class name

6. Java Program Structure

class ClassName {
    public static void main(String[] args) {
        // code
    }
}

7. Comments in Java

// Single-line comment

/*
 Multi-line
 comment
*/

8. Keywords & Identifiers

Keywords:- Reserved words in Java (cannot be used as variable names) Example:

class, public, static, void

Identifiers:-

Names given to variables, classes, and methods. Rules:

  • Cannot start with a number

  • Cannot use keywords

  • No spaces allowed

9. Common Beginner Errors

  • Missing semicolon ( ; )

  • Wrong class name

  • JDK not configured

  • main() method written incorrectly

10. Practice Tasks

  • Install JDK and verify version

  • Write and run the first Java program

  • Modify output message

  • Add comments to code

Module Outcome

  • After completing this module, you should be able to:

  • Install and configure Java

  • Set up a Java IDE

  • Write and run basic Java programs

  • Understand basic Java syntax