Set up the Java development environment and understand the basic structure and syntax of a Java program.
- Download JDK (Java 17 or later – LTS recommended)
- Install using default settings
Open terminal / command prompt and run:
java -version
javac -version
If the version is displayed, Java is installed correctly.
Set the following variables:
-
JAVA_HOME
Example:C:\Program Files\Java\jdk-17
-
Add to PATH:
%JAVA_HOME%\bin
Restart the system after 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.
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
-
Java is case-sensitive
-
Every statement ends with ;
-
Code blocks use { }
-
File name should match class name
class ClassName {
public static void main(String[] args) {
// code
}
}// Single-line comment
/*
Multi-line
comment
*/Keywords:- Reserved words in Java (cannot be used as variable names) Example:
class, public, static, voidIdentifiers:-
Names given to variables, classes, and methods. Rules:
-
Cannot start with a number
-
Cannot use keywords
-
No spaces allowed
-
Missing semicolon ( ; )
-
Wrong class name
-
JDK not configured
-
main() method written incorrectly
-
Install JDK and verify version
-
Write and run the first Java program
-
Modify output message
-
Add comments to code
-
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