Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 119 ยท Getting Started

Advanced Java: Introduction

Start the Advanced Java course. See the backend ecosystem map (JDBC, JSON, testing, REST, JPA, Spring Boot) and run real database, HTTP and JUnit code.

You already know the Java language: classes, generics, collections, lambdas, streams, exceptions and threads. That is the foundation. But almost nobody is paid to write programs that only print to the console. Real Java code talks to databases, reads and writes JSON, answers HTTP requests, is covered by automated tests, is built by a build tool and runs in a container on a server somewhere. Advanced Java is the name for all of that: the libraries, frameworks, standards and habits you need to build backend and enterprise software.

This course takes you from "I know Java" to "I can build, test and ship a real backend service". You will learn the standards everything else is built on (JDBC, HTTP, the Servlet API, JPA) before the frameworks that hide them (Hibernate, Spring, Spring Boot), so that nothing in a production codebase feels like magic. Every chapter has live examples you can edit and run right on the page.

If some core topic feels shaky along the way, the Java course is always one click away. This course links to it instead of repeating it.

What "advanced Java" actually means

The phrase is used loosely. Some people mean "the hard parts of the language" (generics, concurrency, the memory model). Others mean "Java EE". In job ads it usually means Java backend development. This course uses that meaning: everything you need around the language to build server-side applications.

A typical backend service written in Java does a handful of jobs:

  1. Receives requests, usually HTTP with JSON bodies, from a browser, a mobile app or another service.
  2. Validates and processes them with business rules written in plain Java.
  3. Stores and loads data, most often in a relational database such as PostgreSQL or MySQL.
  4. Talks to other systems: calls other APIs, publishes messages, sends emails.
  5. Answers with a status code and a JSON body.

Around that core sit the things that make it professional: automated tests, logging, configuration per environment, security, a reproducible build and a way to deploy it. Each of those has a well-known set of tools in the Java world, and each one has a chapter in this course.

Where advanced Java runs in the real world

The same building blocks appear in very different products, and each domain stresses a different part of the toolbox:

Domain What the Java service does What matters most
Banking and payments account balances, transfers, card authorization, fraud checks transactions and consistency (JDBC Transactions), audit trails, security, idempotent APIs
E-commerce catalog, cart, orders, stock, payments, notifications REST APIs, JPA, search, caching, messaging between services, peak-load scaling
Cloud and SaaS platforms multi-tenant APIs, background jobs, usage billing containers (Docker for Java), configuration per environment, observability, horizontal scaling
Telecom and logistics event streams, tracking, routing, batch settlement messaging, batch processing (Spring Batch), reliability
Government and enterprise back offices long-lived internal systems, integration with legacy services stability, SOAP/XML and JMS integration, backward compatibility

A typical application in these domains is built in layers: a web layer (servlets, JAX-RS or Spring MVC controllers) receives requests; a service layer holds the business rules; a persistence layer (JDBC, JPA, Spring Data) talks to the database; and cross-cutting parts such as security, logging and transactions wrap them all (Layered Architecture). In the cloud the layers are packaged as containers, started several times behind a load balancer, configured from the environment and watched by health checks and metrics.

The ecosystem map

Java's backend ecosystem is big, and its names are confusing at first. This table is the map you can come back to. Each row is a layer; the right column says where you learn it.

Layer Main technologies What it does Chapter
Build Maven, Gradle Downloads libraries, compiles, tests and packages your code Getting Started
Database access JDBC, connection pools (HikariCP) Sends SQL to a database and reads the results Databases with JDBC
Data formats Jackson (JSON), XML APIs, CSV Turns Java objects into text and back Data Formats
Testing JUnit 6, Mockito, Testcontainers Proves your code works, automatically, on every build Testing
Tooling SLF4J + Logback, JFR, static analysis Logs, profiling and code quality Logging and Tooling
HTTP java.net.http.HttpClient, REST Calls APIs and designs your own Web Fundamentals
Jakarta EE web Servlets, JSP, filters, sessions The standard API under every Java web server Servlets and JSP
Persistence JPA, Hibernate Maps objects to tables so you write less SQL JPA and Hibernate
Application framework Spring (IoC, AOP, MVC) Wires your objects together and handles cross-cutting concerns Spring Framework
Production framework Spring Boot, Spring Data, Spring Security Auto-configured, runnable services with batteries included Spring Boot
Architecture Layers, microservices, messaging, Docker How larger systems are split, connected and deployed Architecture and Deployment

Notice the pattern: lower rows are standards or small libraries; higher rows are frameworks built on top of them. Spring Data JPA calls JPA, which Hibernate implements, which calls JDBC, which calls the database driver. When something goes wrong in a Spring Boot app (a slow query, a connection leak, a transaction that did not roll back), the cause is almost always in one of those lower layers. Developers who know the layers fix it in minutes. Developers who only know the annotations guess.

Standards vs. frameworks. A specification (JDBC, Servlet, JPA, Bean Validation) defines interfaces; implementations (a MySQL driver, Tomcat, Hibernate) provide the code. You program against the interfaces, so you can switch implementations. Spring is not a specification, but it builds on many of them, which is why learning the standards first pays off twice.

Java EE, Jakarta EE and Spring in one paragraph

For years, enterprise Java meant Java EE, a set of specifications from Sun and later Oracle. In 2017 Oracle handed it to the Eclipse Foundation, where it became Jakarta EE. Because of trademark rules the package names had to change from javax.* to jakarta.* (starting with Jakarta EE 9), so you will meet both spellings in old and new code. Spring started in 2003 as a lighter alternative to the heavy Java EE of the time and became the most widely used Java framework. Today the two are not enemies: Spring Boot runs on an embedded Jakarta Servlet container (Tomcat by default), uses Jakarta Persistence (JPA) through Hibernate and Jakarta Bean Validation. You will see exactly how they fit together in Jakarta EE Overview and Spring Framework Introduction.

Versions this course uses

The course teaches current versions and tells you when something is new:

  • Java 25, the current long-term support (LTS) release. Code uses modern features such as records, var, text blocks, switch expressions and pattern matching wherever they make the code clearer.
  • JUnit 6 for tests, Jackson 2 for JSON (with notes on Jackson 3, which renamed its packages), and H2 as an in-memory database.
  • Spring Framework 7 and Spring Boot 4, Hibernate 7 and Jakarta EE 11 in the framework chapters.

Most of what you learn also applies to the older versions you will meet in existing projects (Java 17 and 21 are still very common at work). Where a feature needs a newer version, the lesson says so.

What runs live on this page, and what doesn't

The examples run on our server with Java 25 and a few libraries already on the classpath:

  • H2, a small database written in Java. jdbc:h2:mem:anything gives you a fresh in-memory database for each run, so you can practice real SQL and JDBC.
  • Jackson (databind, core, annotations and the Java time module) for JSON.
  • JUnit 6 (Jupiter API, parameterized tests and the launcher), so you can run real test classes.
  • The JDK's own HttpServer and HttpClient. A program cannot reach the internet, but it can start a server on 127.0.0.1 and call it, which is enough for real HTTP and REST demos.

Some things cannot run in a short-lived sandbox: Spring Boot applications, Hibernate, Servlet containers, Maven and Gradle builds, Docker and Kafka. Those lessons show the real code and configuration as read-only blocks and explain what you would see. Then, wherever possible, they add a runnable example that shows the same idea with what is available: a hand-written dependency injection container next to Spring's, a JDBC query next to its JPA version, an HttpServer endpoint next to a Spring @RestController. You learn what the framework does by building a small version of it yourself.

A first taste: from SQL to JSON

Here is the core loop of most backend code in about thirty lines. The program creates an in-memory database, inserts some rows, queries them with SQL, maps each row to a Java record and prints the result as JSON. Press Run, then try changing the WHERE clause.

Java SQL in, JSON out

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

The output is a JSON array with three objects, the in-stock products from the most to the fewest units. Four technologies are working together here:

  • JDBC (Connection, Statement, ResultSet) sends SQL and reads rows. You will learn it properly in JDBC Introduction and CRUD with JDBC, including why real code uses PreparedStatement instead of Statement.
  • H2 is the database, chosen by the jdbc:h2: URL. Swap the URL and driver, and the same code talks to PostgreSQL.
  • A record holds each row. Records are ideal for data that only moves from one layer to another (Records).
  • Jackson turns the list into JSON without any configuration, because it understands records. Its details are in JSON with Jackson.

Every resource is opened in a try-with-resources block, so the connection, statement and result set are closed even if a query throws. That habit matters far more with real databases than with an in-memory one; try-with-resources explains the mechanics.

A tiny backend service

Now put HTTP in front of the database. This program starts a real web server on a free port of 127.0.0.1, registers one endpoint that returns the products as JSON, and then calls it with the JDK's HTTP client, exactly as another service or a browser would.

Java An HTTP endpoint backed by a database

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

The response has status 200, the content type application/json and a compact JSON array of all three products. This is a complete, if tiny, REST endpoint: an HTTP request comes in, SQL runs, JSON goes out. A Spring Boot version of the same endpoint is about ten lines, because the framework handles the server, the routing, the JSON conversion and the connection management for you:

Java
@RestController
@RequestMapping("/api/products")
class ProductController {
    private final ProductRepository products;

    ProductController(ProductRepository products) {
        this.products = products;
    }

    @GetMapping
    List<Product> all() {
        return products.findAll();
    }
}

That code cannot run here, but by the time you reach Building REST APIs with Spring Boot you will know exactly what each annotation replaces, because you will have written those parts by hand in Building a REST API with the JDK.

Tests are part of the code

Professional Java code ships with automated tests. JUnit is the standard test framework, and build tools run its tests on every build. In a normal project you would run them with mvn test or ./gradlew test. Here, a few lines of launcher code run a test class and print one line per test:

Java Your first JUnit run

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

All three tests print SUCCESSFUL. Now break the code on purpose: delete .replaceAll("^-|-$", "") and run again. The third test reports FAILED with JUnit's message showing the expected and actual values. That instant feedback is why teams write tests. The Testing chapter covers JUnit, test doubles, test-driven development and integration tests against a real database.

How to use this course

The chapters are ordered so that each builds on the ones before it, and you will get the most out of it by following that order at least through the JDBC chapter:

  1. Getting Started: your tools. JDKs, IDEs, project layout, then Maven and Gradle, the build tools every Java project uses.
  2. Databases with JDBC: SQL from Java, safely and efficiently. Everything later (JPA, Spring Data) sits on top of this.
  3. Data Formats and Testing: JSON, XML, CSV, and the testing skills employers expect.
  4. Logging and Tooling and Web Fundamentals: logs, debugging, HTTP, REST and web security.
  5. Servlets and JSP, JPA and Hibernate, Spring Framework and Spring Boot: the frameworks, each explained from the standard underneath.
  6. Architecture and Deployment, Projects, and Practice and Review: larger designs, three complete projects, a cheat sheet and interview questions.

Before you start, make sure you are comfortable with these core topics, since every lesson uses them: interfaces, records, exceptions and try-with-resources, collections, generics, lambdas and streams, and annotations. Small examples use Java 25's compact source files (void main() with IO.println); larger ones use a classic public class Main with System.out.println, which is what you will see in most real projects.

Edit everything. Every runnable example is yours to change. The fastest way to learn a library is to break it and read the error. Each run starts from scratch, so you cannot damage anything.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In the first example, what decides that the code talks to H2 rather than PostgreSQL?

    The jdbc:h2: prefix selects the H2 driver. The java.sql interfaces are the same for every database; the URL (and the driver on the classpath) decides which one you reach.
  2. 2. A Spring Boot app is slow because every request opens a new database connection. Which layer is the problem really in?

    Spring Data and JPA sit on top of JDBC and a connection pool. Connection handling is a JDBC-level concern, which is why this course teaches the lower layers first.
  3. 3. Why are Java EE packages called jakarta.* in new code instead of javax.*?

    The APIs are the continuation of Java EE. Only the namespace changed, from Jakarta EE 9 onward, so older code uses javax.servlet and newer code jakarta.servlet.
  4. 4. In the JUnit example, you remove .replaceAll("^-|-$", "") from slugify. What happens?

    Only " --Spring Boot!-- " produces leading and trailing dashes after the first replacement, so only trimsLeadingAndTrailingSeparators fails.

Summary

  • Advanced Java here means backend development: databases, data formats, testing, HTTP and REST, Jakarta EE, JPA/Hibernate, Spring and Spring Boot, architecture and deployment.
  • The ecosystem is layered: frameworks (Spring Boot, Spring Data, Hibernate) are built on standards (JPA, Servlet, JDBC). Knowing the lower layers is what lets you debug the upper ones.
  • Java EE became Jakarta EE, and javax.* became jakarta.* from Jakarta EE 9 on. Spring builds on several Jakarta specifications.
  • Examples run live with Java 25, H2, Jackson, JUnit 6 and the JDK's HTTP server and client. Framework code that can't run here is shown read-only, next to a runnable version of the same idea.
  • A real backend loop is small: request in, SQL through JDBC, rows mapped to records, JSON out, and tests that prove it works.

Next: Setting Up a Java Development Environment, where you install a JDK, pick an IDE and learn the project layout every Java build tool expects.