1. Introduction
The PDF in the document is HERE.
The codes in this document are HERE.
This document is a product of Anthropic’s AI Claude. It is the Java port of the course “Learning the C# Language 14 with .NET 10” (October 2026), which itself is a rewrite of the course “Learning the C# Language Version 3.0 with the .NET 3.5 written by Serge Tahé in May 2008. It retains the course outline, examples, and central theme, and rewrites them in modern Java:
- the document uses Java 25 (September 2025), the latest long-term support version of Java (LTS), and presents, throughout the chapters, the language’s new features—from Java 25’s compact source files to Java 21’s virtual threads, including records, sealed classes, and pattern matching;
- where the two languages differ, the document does more than simply translate: C# properties, structures, operator overloading, and delegates do not exist in Java, which has its own solutions (getters, records, functional interfaces); conversely, Java has concepts unique to itself, such as checked exceptions and virtual threads, and these are presented in detail;
- Two chapters take on a different focus: asynchronous programming, which Java handles using the [CompletableFuture] classes and virtual threads rather than the [async] / [await] keywords, and the object-relational mapping, provided by Hibernate, the most widely used ORM in the Java world;
- the libraries are those currently used in Java: [JUnit 6] for testing, [Spring Framework 7] for dependency injection, [Jackson 3] for JSON, the [MySQL Connector/J] driver for JDBC, [Hibernate 7], and [Spring Boot 4] for web services; the projects are built using [Maven].
This document is not a comprehensive course. Like the ones from which it is derived, it is intended for people who already know how to program and want to learn the basics of Java. It uses examples: more than two hundred programs (more than three hundred Java files), most of them short, with line-by-line comments.
1.1. Java from 1995 to 2026
Java was released by Sun Microsystems in May 1995. It is based on an idea that has been key to its success: the [javac] compiler does not produce machine code but rather an intermediate code—bytecode—stored in [.class] files, which the Java Virtual Machine (the JVM, “Java Virtual Machine”) executes by compiling it on the fly into machine code. A single compiled program can thus run on Windows, Linux, or macOS: “write once, run anywhere.” The Kotlin, Scala, and Groovy languages also produce bytecode and use the same libraries.
Key milestones:
- 2006–2007: OpenJDK. Sun released the Java source code under an open-source license (JDK). All current Java distributions are built from OpenJDK;
- 2010: Oracle acquires Sun and becomes the primary contributor to Java;
- 2014: Java 8, a pivotal release: lambda expressions, API Stream, the new date and time API. Many programs in production are still written in this style;
- Since 2017 (Java 9): A new version of Java is released every six months, in March and September. Some versions have long-term support (LTS, “Long-Term Support”): Java 11 (2018), 17 (2021), 21 (2023), and 25 (September 2025), which is used in this document; starting with Java 17, a new version is released every two years. The other versions are supported for only six months; new features often appear first as “previews” before being finalized in a subsequent version;
- JDK is distributed by several vendors, all of which are based on OpenJDK and are equivalent for our purposes: Oracle, the Eclipse Foundation (Eclipse Temurin, Adoptium project), Microsoft, Amazon (Corretto), and Linux distributions.
The language has evolved significantly since Java 8. The following table summarizes the main new features presented in this document and indicates the chapter in which they appear:
Version | Year | Key New Features | Chapter |
Java 8 | 2014 | lambda expressions, method references, API Stream, interface methods, [default], [java.time], [CompletableFuture] | 5, 7, 9 |
Java 9 | 2017 | modules (JPMS), [jshell], immutable collections [List.of], [Map.of] | 2, 4, 5 |
Java 10 | 2018 | Type inference for local variables [var] | 3 |
Java 11 | 2018 | client HTTP [java.net.http.HttpClient], direct execution of a source file [java File.java], methods [strip], [repeat], [lines] strings | 2, 5, 12 |
Java 14 | 2020 | expressions [switch] ([case ->], [yield]), detailed messages for [NullPointerException] | 3, 4 |
Java 15 | 2020 | text blocks ["""] | 3 |
Java 16 | 2021 | records, pattern filtering with [instanceof] | 4 |
Java 17 | 2021 | Sealed classes and interfaces ([sealed], [permits]) | 4 |
Java 18 | 2022 | UTF-8 as the default encoding | 5 |
Java 21 | 2023 | Virtual threads, sequenced collections, pattern filtering in [switch], record patterns | 3, 4, 5, 8, 9 |
Java 22 | 2024 | Anonymous variables and parameters [_], launching programs from multiple source files | 3, 4, 7 |
Java 24 | 2025 | Intermediate stream operations ([Gatherers]) | 5, 7 |
Java 25 | 2025 | Compact source files and instance methods ([main]), class ([IO]), module imports, scoped values ([ScopedValue]) | 2, 3, 8 |
In terms of libraries and tools, the new features presented include: the [Maven] build tool, modern collections, the API Stream, the [java.nio.file] file API, the [java.util.concurrent] classes, the Java 11 client HTTP, and major frameworks in the ecosystem: JUnit, Spring, Jackson, Hibernate, and Spring Boot.
1.2. Document Contents
The document includes the following chapters:
- Chapter 2: Setting up the development environment (JDK 25, IntelliJ, IDEA, or VS Code, Maven, the [java] and [javac] commands);
- Chapter 3: Language Fundamentals (types, operators, control statements, checked and unchecked exceptions, enumerations, parameter passing);
- Chapter 4: Classes, records, interfaces, inheritance, sealed classes, generics, packages, pattern matching;
- Chapter 5: Commonly Used Java Classes: Strings, Arrays, Collections, API Streams, Text and Binary Files, JSON with Jackson, Regular Expressions;
- Chapter 6: Layered architectures, unit testing with JUnit 6, and dependency injection with Spring;
- Chapter 7: Functional interfaces, lambda expressions, and events;
- Chapter 8: Execution threads, synchronization, and virtual threads;
- Chapter 9: Asynchronous programming with [CompletableFuture] and virtual threads;
- Chapter 10: Database access with JDBC;
- Chapter 11: Hibernate;
- Chapter 12: Web Programming (TCP/IP, TCP clients and servers, HTTP with [HttpClient]) ;
- Chapter 13: Web Services with Spring Boot;
- Chapter 14: Going Further;
- Appendices: Installing Laragon and MySQL, the Maven dependencies used.
1.3. The Common Thread: Tax Calculation
The same problem is revisited throughout the document: calculating the income tax for a taxpayer who has only their salary to report. The tax bracket used is the original one (2003 income): it is no longer current, but it suffices for our purpose, which is to write the same application in several different ways. It is implemented in nine versions:
Version | Chapter | Content |
1 | 3 | A single program: validated input, calculation, display |
2 | 4 | Classes and interfaces: [TaxBracket], [ITax], [AbstractTax], [HardwiredTax] |
3 | 5 | calculation data read from a text file or a JSON file |
4 | 6 | A layered architecture ([dao], [business], [ui]) within a single program |
5 | 6 | One Maven module per layer, unit tests, and integration of layers via dependency injection |
6 | 10 | a [dao] layer that reads data from a MySQL database using JDBC |
7 | 11 | a [dao] layer written with Hibernate |
8 | 12 | a TCP tax calculation server and its client |
9 | 13 | a REST web service for tax calculation, a console client, and a web client |
Starting with version 5, subsequent versions reuse the layers from version 5 and replace only the layer that has changed: this is the whole point of the layered architecture presented in Chapter 6.
1.4. Examples
The code in this document is organized in a single folder named [java-oct-2026], with one subfolder per chapter:
The small programs are compact source files: a single file named [.java], executed using the command [java File.java] (Chapter 2). Multi-file programs that use only the libraries from JDK are launched in the same way. Programs that require an external library (Jackson, JUnit, Spring, the MySQL driver, Hibernate, Spring Boot) are Maven projects ([pom.xml]).
All programs in this document were compiled without errors or warnings by the [javac] compiler from JDK 25, using the [-Xlint:all] option that enables all warnings, and were run using the library versions listed in the appendix. The results reproduced in this document are those of these executions. Those of Chapters 2 to 4 were obtained using the French language and country settings (fr-FR), as on a French Windows system: formatted floating-point numbers are displayed with a decimal comma, and dates are in French; the following chapters were run with English settings (decimal point, dates in English). Two notes:
- the error messages from JDK (exception messages, compiler messages) are in English: JDK does not provide a French translation for them;
- the examples were run on Linux. For the most part, this makes no difference: Java is cross-platform. The few differences (file paths with / instead of \, terminal commands) are noted where they occur.
The results of multithreaded, asynchronous, or network programs, as well as the measured execution times, may vary from one run to another: the comments focus on what is reproducible.
1.5. Sources
The main sources for this document are:
- the official Java documentation: the website https://dev.java (tutorials) and the documentation for the API Java SE 25: https://docs.oracle.com/en/java/javase/25/;
- Java enhancement proposals (JEP, “JDK Enhancement Proposals”), which describe in detail each new feature of the language and platform: https://openjdk.org/jeps/0;
- the documentation for each library: JUnit (https://docs.junit.org), Spring (https://spring.io/projects), Hibernate (https://hibernate.org/orm/documentation/), Jackson (https://github.com/FasterXML/jackson);
- two reference books: “Effective Java” by Joshua Bloch (Addison-Wesley) and “Java Concurrency in Practice” by Brian Goetz et al. (Addison-Wesley), which remain excellent reads.