Free Java Books: Legally Free Java and JVM Programming Books, Beginner to Advanced
A curated list of free Java books and free JVM language books (Kotlin, Scala, Clojure) that you can read legally online or download from the author, university or official project. It runs from your first main method through object-oriented design, data structures and algorithms, concurrency, the JVM itself and frameworks like Spring, and says what each book is best for so you can choose quickly.
Last reviewed: December 2026. At review time the current Java release referenced on dev.java was Java 27, and the most recent long-term-support (LTS) release was Java 25. “Free” means free from an official source (author, university, publisher, official docs or open license).
Table of Contents
- Quick Picks
- What Counts as Legally Free
- Which Java Version Should Books Cover
- Reading Paths with Time Estimates
- Level 1: Absolute Beginner
- Level 2: Object-Oriented Programming and Problem Solving
- Level 3: Data Structures and Algorithms in Java
- Level 4: Professional Java
- The JVM, Specifications and Performance
- Frameworks and Build Tools
- Kotlin
- Scala
- Clojure
- Interpreters and Compilers in Java
- Free Courses and Practice
- Excellent Paid Books (Clearly Marked)
- Old Resources to Use Carefully
- Comparison: Which First Java Book
- Practice Projects
- FAQ
- Where to Go Next
- Contributing
- License
Quick Picks
| You are… | Best free pick | Why |
|---|---|---|
| New to programming | Think Java, 2nd ed. | Short, clear, designed for first-time programmers; also aligned with AP Computer Science A topics. |
| A student wanting a complete textbook | Introduction to Programming Using Java (Javanotes 9) | Over 770 pages covering basics to GUI (JavaFX), threads, networking; free HTML and PDF. |
| Want lots of exercises | Java Programming MOOC (University of Helsinki) | Hundreds of auto-graded exercises; one of the most effective free ways to learn Java. |
| Already code in another language | dev.java Learn | The official, modern tutorial: records, pattern matching, virtual threads, JShell. |
| Studying data structures and algorithms | Algorithms, 4th ed. booksite and Open Data Structures | Princeton’s companion site with code and summaries, plus a fully open DSA textbook. |
| Want design patterns | Java Design Patterns | Hundreds of patterns with code, explanations and diagrams. |
| Moving to Kotlin | Kotlin documentation and Kotlin Koans | Official, excellent, interactive. |
What Counts as Legally Free
Only books deliberately made free are listed: open licenses (Creative Commons), free-to-read official websites, university course texts and official documentation. No “free PDF” mirror sites. Report anything that stops being free.
Which Java Version Should Books Cover
Java changes fast now (a release every six months). Many free books were written for Java 8 or 11. That is fine for fundamentals: loops, classes, collections and generics have not changed. But modern code uses features that older books lack:
| Feature | Arrived in | Why it matters |
|---|---|---|
var local type inference |
Java 10 | Less boilerplate. |
| Switch expressions | Java 14 | Cleaner branching. |
| Text blocks | Java 15 | Multi-line strings. |
| Records | Java 16 | Concise immutable data classes. |
| Sealed classes | Java 17 | Closed hierarchies for safer modeling. |
Pattern matching for switch, record patterns |
Java 21 | Data-oriented programming. |
| Virtual threads | Java 21 | Cheap concurrency for servers. |
Practical advice: use an older free book for fundamentals, then read dev.java Learn for modern features. Install a current LTS JDK.
Reading Paths with Time Estimates
Roughly one hour a day, five days a week, exercises included.
Path A: Zero to confident Java (12 to 16 weeks)
| Weeks | Read | Do |
|---|---|---|
| 1-5 | Think Java | Every exercise; read the debugging appendices. |
| 6-10 | Java Programming MOOC, parts 1-7 | Submit all exercises; aim for full marks. |
| 11-14 | Javanotes chapters on OOP, generics, collections | Build a small library management app. |
| 15-16 | dev.java Learn on records, pattern matching, streams | Refactor your app to modern Java. |
Path B: Programmer from another language (3 to 5 weeks)
| Week | Read | Do |
|---|---|---|
| 1 | dev.java: Getting Started and language basics | Port a program you know. |
| 2 | dev.java collections, streams, generics, lambdas | Rewrite loops as streams, then decide when not to. |
| 3 | Maven getting started or Gradle user guide, and JUnit user guide | Set up a project with tests. |
| 4-5 | Spring guides | Build a REST service with persistence. |
Path C: Data structures and algorithms (8 to 12 weeks)
| Weeks | Read | Do |
|---|---|---|
| 1-3 | Think Data Structures | Implement each structure; run the profiling exercises. |
| 4-8 | Algorithms booksite | Sorting, searching, graphs, strings; use the provided code. |
| 9-12 | Open Data Structures | Analysis-heavy chapters for depth. |
Level 1: Absolute Beginner
| Book | Author(s) | Best for | License / access |
|---|---|---|---|
| Think Java, 2nd ed. | Allen B. Downey, Chris Mayfield | First programming book. Read online, PDF, example code. | CC BY-NC-SA 4.0 |
| Introduction to Programming Using Java, 9th ed. | David J. Eck | Complete free textbook (version 9.0, 2022, covers Java 17 and JavaFX). Linked and print-ready PDFs available. | CC BY-NC-SA 4.0 |
| Introduction to Programming in Java booksite | Robert Sedgewick, Kevin Wayne | Princeton’s intro course companion: summaries, code and exercises (the full textbook is sold separately). | Free online booksite |
| Java Programming (Wikibook) | Wikibooks contributors | Broad community reference; use as a supplement. | CC BY-SA |
| The Java Tutorials | Oracle | Classic official tutorial; written for JDK 8, still good for fundamentals. | Free (official) |
| dev.java Learn | Oracle Java team | The modern official tutorial: first steps, language, APIs, JVM tools, JavaFX. | Free (official) |
| Java Introduction notes | Ray Toal (LMU) | Fast, example-heavy overview for people who already program. | Free online |
Best pick: Think Java to start; Javanotes if you want one big book that goes much further.
Level 2: Object-Oriented Programming and Problem Solving
| Book | Author(s) | Best for | License / access |
|---|---|---|---|
| Java, Java, Java: Object-Oriented Problem Solving, 3rd ed. | Ralph Morelli, Ralph Walde | OOP-first CS1 textbook; PDF, LaTeX and online. Older (2016). | CC BY 4.0 |
| Javanotes chapters 5-10 | David J. Eck | Objects, inheritance, interfaces, generics, collections, GUI. | CC BY-NC-SA 4.0 |
| Java Design Patterns | Community (GitHub) | Pattern catalog with runnable code for each. | MIT |
| Google Java Style Guide | A concrete, widely used style standard. | CC BY 3.0 |
Level 3: Data Structures and Algorithms in Java
| Book | Author(s) | Best for | License / access |
|---|---|---|---|
| Think Data Structures | Allen B. Downey | Short, practical DSA through building a search engine; with profiling. | CC BY-NC-SA |
| Open Data Structures (Java edition) | Pat Morin | Rigorous, open DSA textbook with analysis; also C++ and Python editions. | CC BY |
| Algorithms, 4th ed. booksite | Robert Sedgewick, Kevin Wayne | Code, summaries and exercises for the famous Princeton algorithms course. The printed book is paid; the booksite is free. | Free booksite |
| CS61B textbook | UC Berkeley CS61B staff | Data structures course notes in Java. | Free online |
| Java Structures | Duane A. Bailey | Classic data structures text from Williams College. Older Java. | Free online |
| Data Structure Visualizations | David Galles (USF) | Watch structures and algorithms animate. | Free |
Best pick: Think Data Structures first, then the Algorithms booksite with the free Coursera-style lectures it links to.
Level 4: Professional Java
| Resource | Best for | Access |
|---|---|---|
| dev.java Learn: Mastering the API | Collections, streams, dates, regex, reflection, virtual threads, modules, jlink. | Free (official) |
| JUnit user guide | Testing (current major version is JUnit 6). | Free (official) |
| Inside.java | News, articles and podcasts from the Java team at Oracle. | Free |
| The Java Specialists’ Newsletter archive | Hundreds of deep articles on concurrency and the JDK. | Free |
| Aleksey Shipilëv’s site | JVM performance, benchmarking, JMM. | Free |
| JMH | The standard microbenchmark harness; its samples teach benchmarking pitfalls. | Free (GPL with classpath exception) |
| Java Concurrency in Practice site | Code listings and errata for the (paid) classic. | Free site, paid book |
The JVM, Specifications and Performance
- Java SE Specifications - the Java Language Specification and JVM Specification for every release, e.g. JLS SE 25 and JVMS SE 25.
- Java SE documentation - API docs, tool guides, GC tuning guides per release.
- OpenJDK and JEP index - every enhancement proposal explains why a feature exists.
- VisualVM - free profiler; learning it is worth a book chapter.
Frameworks and Build Tools
| Guide | Notes |
|---|---|
| Spring guides | Short task-focused guides (REST service, data JPA, security). |
| Spring Boot reference and Spring Framework reference | The full official docs. |
| Quarkus guides | Cloud-native Java with fast startup. |
| Maven getting started | Build basics. |
| Gradle user manual | Build basics with Gradle. |
| Java on Microsoft Learn | Java on Azure and VS Code. |
Kotlin
| Resource | Best for | Access |
|---|---|---|
| Kotlin documentation | The official language guide; reads like a book. | Free |
| Kotlin Koans (online) | Learn by fixing small failing exercises. | Free |
| Coroutines guide | Structured concurrency in Kotlin. | Free |
| Android: Kotlin first and Android courses | Android development with Kotlin and Jetpack Compose. | Free |
| Exercism Kotlin | Practice with mentoring. | Free |
| Kotlin in Action, 2nd ed. (Manning) | In-depth book from Kotlin team members. | Paid |
Scala
| Resource | Best for | Access |
|---|---|---|
| Scala 3 Book | The official introduction to Scala 3. | Free |
| Creative Scala | Learning Scala and functional programming through drawing; good for beginners. | Free online |
| Essential Scala | Core Scala patterns for programmers; older (Scala 2). | Free |
| Scala with Cats | Type classes, functors, monads with the Cats library. The site now recommends its successor, Functional Programming Strategies. | Free online |
| Typelevel Cats docs | Functional abstractions reference. | Free |
| Functional Programming in Scala, 2nd ed. (Manning) | The classic “red book” for FP. | Paid |
Clojure
| Resource | Best for | Access |
|---|---|---|
| Clojure for the Brave and True | Fun, thorough beginner book. Free online; print is paid. | Free online |
| Learn Clojure guide and Getting started | Official short guides. | Free |
| Exercism Clojure | Practice exercises. | Free |
Interpreters and Compilers in Java
Crafting Interpreters by Robert Nystrom is free to read online. Its first half builds a tree-walking interpreter in Java (the second half switches to C). It is one of the best books for intermediate Java developers who want to understand how languages work and practise writing a substantial program.
Free Courses and Practice
| Resource | Notes |
|---|---|
| Java Programming MOOC | University of Helsinki; two parts, hundreds of exercises. |
| CodingBat Java | Short warm-up problems with instant feedback. |
| Programming by Doing | A long sequence of small assignments for beginners. |
| Exercism Java | Practice with optional mentoring. |
| HackerRank Java domain | Language-feature drills. |
| CMU 15-121 | Intro to data structures course pages in Java. |
Excellent Paid Books (Clearly Marked)
| Book | Why recommended | Status |
|---|---|---|
| Effective Java, 3rd ed. (Joshua Bloch) | The standard book on writing good Java APIs and code. | Paid |
| Java Concurrency in Practice (Brian Goetz et al.) | Still the reference for the Java memory model and thread safety. | Paid |
| Algorithms, 4th ed. (Sedgewick, Wayne) | The book behind the free booksite above. | Paid |
| Head First Java, 3rd ed. | Very visual beginner book. | Paid |
Old Resources to Use Carefully
- The Java Tutorials (Oracle) - says it targets JDK 8; still accurate for fundamentals, but use dev.java for modern Java.
- Java, Java, Java (2016) and Java Structures - solid concepts, older syntax.
- Essential Scala - Scala 2 era.
- Anything that teaches Applets or Java Web Start - obsolete; skip those chapters.
Comparison: Which First Java Book
| Think Java | Javanotes | Java Programming MOOC | dev.java Learn | Java, Java, Java | |
|---|---|---|---|---|---|
| Length | Short | Very long | Course | Medium | Long |
| Java version | Java 8+ | Java 17 | Recent | Current | Older |
| Exercises | Yes | Yes, with solutions | Hundreds, autograded | Few | Yes |
| GUI coverage | Minimal | JavaFX | Some | JavaFX section | Swing |
| Best for | First-time programmers | Full CS1/CS2 textbook | Practice volume | Experienced programmers | OOP-first classes |
Practice Projects
Beginner: temperature converter; grade calculator reading from a text file; tic-tac-toe in the console; bank account class with deposits and withdrawals and tests.
Intermediate: library management system using collections and records; command-line contact book with file persistence; a JSON parser for a small subset; implement ArrayList, HashMap and a binary heap with JUnit tests.
Advanced: a Spring Boot REST API with PostgreSQL, validation and integration tests; a multithreaded web crawler using virtual threads; a tree-walking interpreter following Crafting Interpreters; a JMH benchmark comparing collection choices, with a write-up.
FAQ
What is the best free Java book for beginners? Think Java for a short first book, or Introduction to Programming Using Java (Javanotes) for a complete textbook. Pair either with the Helsinki Java MOOC for practice.
Is there a free Java PDF that’s legal? Yes: Think Java and Javanotes both offer official free PDFs from their authors, and Java, Java, Java is CC BY with a PDF on the Open Textbook Library.
Which Java version should I learn in 2026? Install the latest LTS (Java 25 at review time). Concepts from books written for Java 8-17 still apply; learn records, switch expressions and pattern matching from dev.java.
Is Java still worth learning? Yes. It is widely used for back-end services, Android (alongside Kotlin), big data tools and enterprise systems, and it is a common university teaching language.
Java or Kotlin first? For Android, Kotlin. For back-end jobs and university courses, Java first is common; Kotlin is easy to pick up after.
How long does it take to learn Java? Core language in 2-3 months part time; junior back-end readiness (Java, Spring, SQL, Git, testing) usually 6-12 months.
Where to Go Next
- free-programming-books-python, free-programming-books-javascript, free-programming-books-cpp, free-programming-books-go-rust
- The big multilingual index: free-programming-books
- More open textbooks: Open Textbook Library
Contributing
Open an issue or pull request with the official URL (no mirrors), license or access terms, edition and the Java version it covers, plus one sentence on who it is best for. Broken links and books that stop being free get removed.
License
This list is released under CC BY 4.0. The books belong to their authors and publishers under their own terms.
If this helped you, a star helps others find it.
More free resources
Part of the Ralpberry Labs open-source collection. See also Top 100 Open Source.