1.1 History, Feature or Buzzwords of Java
Java is a popular, platform-independent computer programming language first introduced in 1995 by Sun Microsystems [cite: 1]. It was primarily developed to run on a great variety of computer systems and devices, earning the famous moniker WORA (Write Once, Run Anywhere) [cite: 3].
The creators of Java defined its core requirements and capabilities using a list of buzzwords. The most important features (buzzwords) of the Java language are:
- Simple: Java is very easy to learn, and its syntax is clean and easy to understand [cite: 2].
- Object-Oriented: Everything in Java revolves around objects and classes [cite: 2].
- Portable: Java code can be executed on any machine without modification [cite: 2].
- Platform Independent: Unlike C/C++, Java is compiled into bytecode that is platform-independent [cite: 2].
- Secured: Java provides robust security features [cite: 2].
- Robust: It features strong memory management and automatic garbage collection [cite: 2].
- Architecture Neutral: The compiler generates an architecture-neutral object file format [cite: 2].
- Interpreted: Bytecode is interpreted into native machine instructions on the fly [cite: 2].
- High Performance: Java enables high performance with the use of Just-In-Time (JIT) compilers [cite: 2].
- Multithreaded: Java supports multiple threads of execution concurrently [cite: 2].
- Distributed: Java is designed for the distributed environment of the internet [cite: 2].
- Dynamic: Java programs can carry extensive amounts of run-time information [cite: 2].
1.2 Java Architecture: JVM, JDK and JRE
Java Architecture defines how the Java programming language works internally, achieving its platform independence [cite: 4]. It mainly consists of three key components:
JVM (Java Virtual Machine)
The engine that runs Java programs. It converts intermediate bytecode into machine code for the current operating system [cite: 4].
- Loads and verifies code [cite: 4].
- Executes code using the JIT Compiler [cite: 4].
- Manages memory (Garbage Collection) [cite: 4].
JRE (Java Runtime Environment)
The environment needed to run a Java program. It consists of the JVM, core libraries, and other supporting components [cite: 4].
- Provides runtime environments [cite: 4].
- Note: JRE alone cannot be used to develop applications [cite: 4].
JDK (Java Development Kit)
The complete toolkit for Java developers. It includes the JRE plus development tools [cite: 4].
- Includes compiler (javac) and debugger [cite: 4].
- Includes JavaDoc tool [cite: 4].

1.3 Procedural-oriented Vs. Object-oriented Programming
Programming paradigms dictate how software is structured. The two dominant paradigms are Procedural Programming and Object-Oriented Programming (OOP) [cite: 5]

1.4 Setting up Java Environment and IDE in Local Machine
To start programming in Java, a proper development environment must be configured on the local machine:
- Install the JDK: Download the Java Development Kit (JDK) corresponding to your operating system.
- Set Environment Variables: Configure the JAVA_HOME variable to point to the JDK installation directory and append the JDK's bin folder to the system's Path variable.
- Verify Installation: Open a command prompt and type java -version and javac -version to verify successful configuration.
- Install an IDE: Download an Integrated Development Environment (IDE) like Eclipse, IntelliJ IDEA, or Visual Studio Code to streamline coding, debugging, and project management.
1.5 Sample Java Programs
A Java program is built inside a class and requires a main method for execution [cite: 1]. Programming statements are known as source code and are saved in a .java file [cite: 1].
public class SampleClass {
public static void main(String args[]) {
// print "Hello Class!!" on the screen when this program runs
System.out.println("Hello Class!!");
}
}
In this example, SampleClass is the class name (identifier) [cite: 1]. The file must be saved as SampleClass.java [cite: 1].
1.6 Compiling and Running Java Program
Java uses a combination of both a compiler and an interpreter [cite: 4]. The flow of execution occurs in two primary steps:
- Compilation: The source code (.java file) is compiled into an intermediate bytecode (.class file) using the Java compiler.
- Command: javac SampleClass.java [cite: 4]
- Execution: The JVM reads the generated bytecode, translates it into system-specific machine code using the Just-In-Time (JIT) compiler, and executes it.
- Command: java SampleClass [cite: 4]
1.7 Command-line Arguments
Command-line arguments allow users to pass values to the program at the time of execution [cite: 6]. These arguments are passed as space-separated values after the program name [cite: 6].
The Java Virtual Machine (JVM) supplies these arguments to the main method as elements of the args[] String array [cite: 6].
public class CommandLineExample {
public static void main(String[] args) {
if (args.length > 0) {
System.out.println("First argument: " + args[0]);
}
}
}
Note: Java treats all command-line inputs as strings. To use numeric inputs, you must parse them explicitly (e.g., Integer.parseInt(args[0])) [cite: 6].
1.8 Scanner Class for Input
The Scanner class is part of the java.util package and is widely used to capture user inputs during program execution [cite: 1].
import java.util.Scanner;
public class KeyboardInput {
public static void main(String[] args) {
// Create a scanner object
Scanner input = new Scanner(System.in);
System.out.print("Enter your message: ");
// Use the scanner object to read line from keyboard
String inputString = input.nextLine();
System.out.println("You entered: " + inputString);
input.close();
}
}
Common methods of the Scanner class include nextLine() for strings, nextInt() for integers, and nextDouble() for decimal numbers [cite: 1].
1.9 Handling Common Errors
During Java programming, developers encounter various errors. Understanding and handling them is critical for robust application development.
- Syntax Errors (Compile-Time): Errors like missing semicolons (;) at the end of statements, using mismatched curly braces, or attempting to assign an incompatible data type (e.g., mixing array types) [cite: 1].
- Array Index Out Of Bounds: Attempting to access an index beyond the valid bounds (0 to length - 1) throws an ArrayIndexOutOfBoundsException [cite: 1].
- Format Errors: Parsing a non-numeric string into an integer throws a NumberFormatException [cite: 6].
- I/O Exceptions: Reading from a file that does not exist throws a FileNotFoundException [cite: 1].
To gracefully handle runtime exceptions and prevent complete system crashes, Java employs try...catch blocks [cite: 1].
try {
// Code that might throw an exception
int number = Integer.parseInt("invalid_number");
} catch (NumberFormatException e) {
// Code to handle the exception
System.out.println("Invalid format encountered.");
}
References
- [1] Provided Java Programming eTextbook (PA-ADOPT).
- [2] Java (Programming Language) Buzzwords, Scribd Document.
- [3] Saral Notes - Java Archives.
- [4] Java Architecture - DEV Community (Swetha Palani).
- [5] Difference Between Procedural and Object-Oriented Programming (CCBP).
- [6] Processing Command-Line Arguments in Java Applications - Medium (Alexander Obregon).