Java is a high-level, class-based, object-oriented, concurrent, and secure general-purpose programming language. Created in 1991 by James Gosling, Mike Sheridan, and Patrick Naughton at Sun Microsystems (later acquired by Oracle Corporation in 2010), the project was originally named Oak, intended for interactive television sets and consumer electronic devices. In 1995, it was renamed Java and repurposed for the rapidly emerging World Wide Web.
Prior to Java, languages such as C and C++ were platform-dependent: source code had to be recompiled into platform-specific machine code for each target CPU architecture (x86, ARM, SPARC) and Operating System (Windows, UNIX, Mac OS). Java revolutionized computing by introducing the revolutionary axiom: "Write Once, Run Anywhere" (WORA). A Java source file is compiled into an intermediate, architecture-neutral format called Bytecode, which executes on any system equipped with a compatible Java Virtual Machine (JVM).
The Java ecosystem is organized into distinct editions tailored to varying software domains:
Since Java 9, Oracle established a predictable six-month release cadence (March and September), with designated Long-Term Support (LTS) releases designated every two years (notably Java 8, Java 11, Java 17, and Java 21) that receive enterprise security patches for up to a decade.
The Sun Microsystems white paper titled "The Java Language: A White Paper" outlines 11 fundamental design tenets that explain why Java remains the backbone of global enterprise infrastructure:
int is always 32-bit signed two's complement, whether running on an Intel 64-bit CPU or an ARM 32-bit mobile chip).| Feature / Dimension | C++ | Java | Python |
|---|---|---|---|
| Execution Model | Direct Native Machine Code | Hybrid (Bytecode + JIT Native) | Interpreted Bytecode (CPython) |
| Memory Management | Manual (`new`, `delete`) | Automatic Garbage Collector (GC) | Automatic Reference Counting + GC |
| Platform Independence | No (Requires OS recompilation) | Yes (WORA via JVM) | Yes (Via Python Interpreter) |
| Pointers Support | Direct pointer arithmetic allowed | No pointers (Safe references only) | No pointers (Object references) |
| Multiple Inheritance | Yes (Classes & Templates) | No for classes; Yes via Interfaces | Yes (Multiple base classes) |
The relationship between the Java Development Kit (JDK), Java Runtime Environment (JRE), and Java Virtual Machine (JVM) follows a strict concentric containment model:
javac, jar, javadoc, javap, jdb
rt.jar / java.base
The life cycle of a Java program is partitioned into two distinct phases: Build-Time Compilation and Runtime Execution:
.java extension (e.g., App.java)..class files (e.g., App.class). Bytecode is completely agnostic of host operating system architecture.java App is invoked, the JVM launches. The ClassLoader subsystem locates and dynamically loads the .class file into the JVM's Method Area.HelloWorld.javajavac ➔HelloWorld.classjava HelloWorld (JVM Launches)
Installing the JDK places developer binaries (like javac.exe and java.exe) deep within a system directory (such as C:\Program Files\Java\jdk-21\bin). Operating systems and enterprise tools (Maven, Gradle, Tomcat, Android Studio, Spring Boot) rely on two fundamental environment variables:
JAVA_HOME: A system variable that points to the root directory where the JDK is installed (e.g., C:\Program Files\Java\jdk-21, NOT the bin subdirectory). Build tools check JAVA_HOME to discover compilers and runtime libraries.PATH: An operating system variable containing a list of directories where executable commands are searched. Appending %JAVA_HOME%\bin (Windows) or $JAVA_HOME/bin (Unix) allows running java and javac from any terminal prompt without typing absolute file paths.# --- Step 1: Verify Java Compiler is in system PATH ---
$ javac -version
javac 21.0.2
# --- Step 2: Verify Java Runtime Environment version ---
$ java -version
openjdk version "21.0.2" 2024-01-16
OpenJDK Runtime Environment (build 21.0.2+13-58)
OpenJDK 64-Bit Server VM (build 21.0.2+13-58, mixed mode, sharing)
# --- Step 3: Inspect JAVA_HOME variable (PowerShell / Command Prompt) ---
# Windows PowerShell:
$ echo $env:JAVA_HOME
C:\Program Files\Java\jdk-21
# Windows CMD:
> echo %JAVA_HOME%
C:\Program Files\Java\jdk-21
# macOS / Linux Bash:
$ echo $JAVA_HOME
/usr/lib/jvm/java-21-openjdk
While simple Java programs can be authored using text editors and compiled on the command line, modern industrial software engineering demands an IDE providing intelligent code completion, refactoring, integrated test runners (JUnit), and graphical debuggers:
main MethodIn Java, every executable statement must reside inside a class. The standard entry point of any standalone Java application is:
public static void main(String[] args)
Understanding each keyword in this signature is a mandatory milestone in mastering Java architecture:
public: An access modifier that specifies the method's visibility. The main method must be public so that the external JVM runtime engine can invoke it from outside the class package without encountering access restriction errors.static: Denotes that the method belongs to the class itself, rather than to an instantiated instance of the class. Because no objects exist when a Java program boots, the JVM can call ClassName.main() directly without allocating an instance via new.void: The return type. Signifies that the method does not return any value to the caller upon completion. Program termination status in Java is communicated via System.exit(int status) rather than method return codes.main: The identifier recognized by the JVM's execution engine as the designated entry point of the program.String[] args: An array of String objects that captures command-line arguments passed to the program at runtime (e.g., java App arg1 arg2)./**
* Standard First Java Program Structure
* Author: DevAscent Academy Engineering
*/
public class HelloWorld {
// The exact entry point required by the Java Virtual Machine
public static void main(String[] args) {
/*
* System.out.println() breakdown:
* System - Predefined final class in the java.lang package
* out - Static member variable of System, an instance of PrintStream
* println() - Public method of PrintStream that prints text + newline
*/
System.out.println("Hello, World from DevAscent Academy!");
System.out.println("Java Version: " + System.getProperty("java.version"));
}
}
Comments are human-readable annotations ignored by the Java compiler during bytecode generation. They serve to document intent, describe algorithms, and generate automated API documentation:
//. Everything from the two slashes to the end of the line is ignored. Used for brief inline notes./* and */. Can span multiple lines. Used for explaining complex blocks or temporarily disabling lines of code during debugging. Block comments cannot be nested!/** and */. Processed by the official javadoc utility to generate standardized HTML documentation. Uses metadata tags such as @author, @version, @param, and @return./**
* Provides mathematical utility operations.
* <p>Demonstrates standard Javadoc formatting.</p>
*
* @author DevAscent Academy
* @version 1.0
* @since 2026-10-15
*/
public class Calculator {
/**
* Calculates the sum of two integers.
*
* @param a the first integer addend
* @param b the second integer addend
* @return the arithmetic sum of {@code a} and {@code b}
*/
public static int add(int a, int b) {
// Inline calculation
return a + b;
}
}
A token is the smallest indivisible syntactic element recognized by the Java compiler during lexical analysis (tokenization). Java source code is composed of 5 distinct token classifications:
+, &&, ==).( ), { }, [ ], ;, ,, .).class, public, voidHelloWorld, totalScore42, 3.14, "Text"+, *, >=, !;, { }, ( ), ,Java reserves over 50 keywords that cannot be used as identifiers. Notable rules and reserved words include:
const and goto are reserved keywords in Java, but have no functionality implemented (they prevent programmers from accidentally using them from C++).true, false, and null are literal values, but are also reserved words that cannot be used as identifiers.A-Z, a-z), digits (0-9), dollar signs ($), and underscores (_).1stPlayer is illegal; player1 is legal).totalScore, TotalScore, and TOTALSCORE are three entirely separate identifiers).StudentProfile, DatabaseConnection.calculateAverage(), maxStudentCount.MAX_RETRY_LIMIT, PI_CONSTANT.me.devascentacademy.core.To solidify the concepts of Unit 1, we build a production-grade console application that combines: command-line argument ingestion (`String[] args`), system environment diagnostics via the Java Standard Library, formatted console streams, and a dynamic lexical identifier validator.
/**
* DevAscent Academy — Unit 1 Capstone Project
* Demonstrates JVM Diagnostics, Arguments Processing, and Identifier Validation.
*/
public class SystemInspector {
public static void main(String[] args) {
System.out.println("==================================================");
System.out.println(" DEVASCENT ACADEMY — JVM ENVIRONMENT INSPECTOR ");
System.out.println("==================================================");
// 1. Querying Runtime Environment Information
String javaVersion = System.getProperty("java.version");
String javaVendor = System.getProperty("java.vendor");
String osName = System.getProperty("os.name");
String osArch = System.getProperty("os.arch");
long totalMemory = Runtime.getRuntime().totalMemory() / (1024 * 1024);
System.out.println("Java Version : " + javaVersion);
System.out.println("Vendor : " + javaVendor);
System.out.println("OS Platform : " + osName + " (" + osArch + ")");
System.out.println("Allocated Heap: " + totalMemory + " MB");
System.out.println("--------------------------------------------------");
// 2. Processing Command-Line Arguments
System.out.println("Command-Line Arguments Received: " + args.length);
for (int i = 0; i < args.length; i++) {
System.out.println(" [Arg " + i + "]: " + args[i]);
}
System.out.println("--------------------------------------------------");
// 3. Lexical Identifier Validity Tester
String[] testIdentifiers = { "validVariable", "_counter", "$price", "2ndPlace", "class" };
System.out.println("Lexical Identifier Validation:");
for (String identifier : testIdentifiers) {
boolean isValid = isValidJavaIdentifier(identifier);
System.out.println(" Identifier: '" + identifier + "' -> " + (isValid ? "VALID" : "INVALID"));
}
}
/**
* Checks if a string conforms to Java Identifier lexical specifications.
*/
public static boolean isValidJavaIdentifier(String s) {
if (s == null || s.isEmpty()) return false;
// Reserved keywords check (abbreviated sample)
if (s.equals("class") || s.equals("public") || s.equals("static") || s.equals("void")) {
return false;
}
// Check first character
if (!Character.isJavaIdentifierStart(s.charAt(0))) {
return false;
}
// Check subsequent characters
for (int i = 1; i < s.length(); i++) {
if (!Character.isJavaIdentifierPart(s.charAt(i))) {
return false;
}
}
return true;
}
}
javac) compiles source code into platform-independent Bytecode. Any operating system equipped with an implementation of the Java Virtual Machine (JVM) can execute this bytecode identically, fulfilling "Write Once, Run Anywhere".
.java file can contain multiple classes, but at most one class can be declared public. The filename must match the name of the public class exactly (including case). If there is no public class in the file, the file can take any valid identifier name. When compiled with javac, each class in the file generates its own separate .class bytecode file.
main method in Java declared static?main method must be static so that the JVM can invoke it directly using the class name (e.g., ClassName.main()) without needing to instantiate an object of that class first. If main were non-static, the JVM would have to create an instance via a constructor; however, if the class lacked a default constructor or required arguments, the JVM would not know how to initialize it.
JAVA_HOME and the PATH environment variable?JAVA_HOME points to the root directory of the installed JDK (e.g., C:\Program Files\Java\jdk-21) and is used by external build tools (Maven, Gradle, Tomcat) to locate the JDK installation. PATH is an operating system variable pointing to directories containing executable binaries. Appending %JAVA_HOME%\bin to PATH allows running java and javac commands from any terminal location.
System.out.print() and System.out.println()?PrintStream). However, print() leaves the console cursor at the end of the printed text on the same line, whereas println() automatically appends a platform-specific newline character (\n or \r\n), moving the cursor to the beginning of the next line.
const and goto keywords in Java?const and goto are reserved keywords in Java, but they currently have no functionality and are not used in the language syntax. They were reserved to prevent programmers transitioning from C/C++ from misusing them and to preserve future language flexibility.