Origins and Ecosystem
Java was introduced by James Gosling in 1995 and is currently maintained by Oracle. While newer versions like Java 15+ exist, Java 8 and Java 11 remain the industry standards due to their long-term support (LTS) status. The ecosystem is categorized into three editions: Java SE (Standard Edition) for core development, Java EE (Enterprise Edition) for server-side applications, and Java ME (Micro Edition) for legacy embedded systems.
Core Characteristics
- Object-Oirented: Java follows the OOP paradigm, promoting modularity through classes and objects.
- Robustness: Features include strict type checking, comprehensive expection handling, and automated garbage collection to manage memory.
- Platform Independence: Compiled bytecode (.class files) runs on any machine with a Java Virtual Machine (JVM), adhering to the "Write Once, Run Anywhere" philosophy.
- Interpreted Nature: Java balances compilation and interpretation. Source code is compiled into bytecode, which the JVM then interprets or compiles at runtime (JIT) into machine-specific instructions.
Development Environment Setup
Java Development Kit (JDK) is the core package comprising the Java Runtime Environment (JRE) and development utilities such as the compiler (javac) and launcher (java).
- Installation: Download the appropriate JDK version.
- Environment Variables: Adding the JDK
bindirectory to the system PATH allows executing development commands from any terminal location.
Application Execution
Every Java application requires a class containing an entry point method. Below is a foundational implementation:
public class Starter {
public static void main(String[] args) {
System.out.println("Initialize system process...");
}
}
Development Rules:
- A single source file can contain multiple classes, but only one may be declared
public. - The filename must match the name of the
publicclass exactly. - Execution occurs by invoking the JVM and specifying the entry class containing the
public static void main(String[] args)signature.
Escape Sequences
When outputting strings to the console, specific backslash sequences provide control over formatting:
\t: Horizontal tab for alignment.\n: Newline character.\\: Represents a single literal backslash.\": Represents a double quote.\': Represents a single quote.\r: Carriage return, moving the cursor to the start of the currrent line.
Documentation and Style Conventions
- Comment Types: Use
//for single-line,/* */for multi-line, and/** */for Javadoc-compliant documentation. - Javadoc: Tools can extract metadata (e.g.,
@author,@version,@return) from Javadoc comments to generate HTML-based technical documentation. - Formatting: Follow clean code practices such as using UTF-8 encoding, limiting lines to 80 characters, and consistently applying indentation via IDE tools. The industry standard prefers the "End-of-line" brace style (placing the opening brace on the same line as the declaration).