Leanpub Header

Skip to main content

Modern Java: Second Edition

Java 21 and the Java Ecosystem

This book will help you understand the latest in Java 8 to 21, asynchronous, reactive programming, build, testing, and web frameworks (and a bit of Groovy and Scala) so you can advance your career in software development. No AI was used! All readers will get all future updates and 20% of proceeds go to EFF.

The author is letting you choose the price you pay for this book!

Pick Your Price...

Buying multiple copies for your team? See below for a discount!

PDF
EPUB
WEB
106
Readers
214
Pages
40,064Words
About

About

About the Book

Who is this for?

This book is for anyone who wants to learn more about Java programming up to and including Java 21. It helps to have a background in some programming language and a basic understanding of Java, but it's not required.

What is covered?

Java and the JVM platform have made huge strides in the past several years. In Project Lambda, Java got lambda expressions, method-references, and default and static methods on interfaces. Java 9 added modularity, jshell, and Reactive support. Java 10-11 added local variable type inference (var) and Java 12-17 added switch expressions, pattern matching instanceof, multi-line strings, and records. Java 18-21 added many features, including virtual threads and scoped values.

At the same time, many new frameworks have reached full maturity and vastly improved over the previous models for building, testing, and developing web applications.

This book will help you understand:

  • The new features released in Java 10-21, such as "var", multi-line strings, records, and virtual threads
  • Java 9+, including: Project Jigsaw, JShell, language updates, and Reactive support.
  • Java 8+, including: Project Lambda, the new Date-Time API, Streams, default methods, Nashorn, and more.
  • Concurrent programming such as Fork/Join, Futures, Promises, Reactor, and RxJava.
  • Great web frameworks in Java, such as Spring Boot, Spark, Play, and Ratpack.
  • The fundamentals of Groovy and how it can improve your Java projects.
  • Testing with JUnit and Spock.
  • Building with Maven and Gradle.
  • Microservices, REST, Cloud...
  • Logback, Hibernate, Guava...
  • Much more...

Disclaimer

Java is a registered trademark of Oracle. You can find Java here on Oracle's website.

Share this book

Price

Pick Your Price...

Minimum price

$29.99

$39.99

You pay

$39.99

Author earns

$25.59

Cause gets

$6.40
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 2)

2
The author will earn $24.00 from your purchase!
You can get credits monthly with a Reader Membership

Team Discounts

Team Discounts

Get a team discount on this book!

  • Up to 3 members

    Minimum price
    $74.00
    Suggested price
    $99.00
  • Up to 5 members

    Minimum price
    $119.00
    Suggested price
    $159.00
  • Up to 10 members

    Minimum price
    $209.00
    Suggested price
    $279.00
  • Up to 15 members

    Minimum price
    $299.00
    Suggested price
    $399.00
  • Up to 25 members

    Minimum price
    $449.00
    Suggested price
    $599.00

Author

About the Author

Adam L. Davis

Adam Davis makes software. He's spent many years developing in Java (since Java 1.2) and has enjoyed using Spring, Hibernate, Grails, and many others. He has used Java, Groovy, JavaScript, AWS, and much more to build applications for over a decade and has worked at both large and small corporations. Adam is a Certified Spring Professional and has a Masters and a Bachelors degree in Computer Science from Georgia Tech.

http://adamldavis.com

Contents

Table of Contents

Introduction

  1. ABL: Always Be Learning
  2. Who is this book for?
  3. What is this book about?
  4. What this book is not about

Starting Out

  1. Part I: Java

Java

  1. History
  2. Openness
  3. The Java Ecosystem

Java Syntax and Conventions

  1. Java JDK
  2. Primitives and Arrays
  3. Classes
  4. Properties and Methods
  5. Comments
  6. Java 5
  7. Java 6

Java 7

  1. Language Updates
  2. Github Repo
  3. Fork/Join
  4. New IO (nio)
  5. JVM Benefits
  6. Performance Benefits
  7. Backwards Compatibility

Idiomatic Java 8: Lambdas, Streams, and Dates

  1. Lambda Expressions
  2. Comparisons to Java 7
  3. Default Methods
  4. Default and Functional
  5. Multiple Defaults
  6. Static Methods on Interface
  7. Streams
  8. For Each
  9. Map/Filter/Reduce
  10. Parallel Array
  11. Peek
  12. Limit
  13. Sort
  14. Collectors and Statistics
  15. Grouping and Partitioning
  16. Comparisons to Java 7
  17. Optional
  18. The Billion Dollar Mistake
  19. Stream Optional
  20. Nashorn

New Date and Time API

  1. New Classes
  2. Creation
  3. Enums
  4. Clock
  5. Period and Duration
  6. Temporal Adjusters
  7. Instant
  8. Time Zones
  9. Backwards Compatibility

Java 8 Miscellaneous

  1. Base64
  2. No More Permanent Generation
  3. Annotations on Java Types
  4. Repeating Annotations
  5. Functional Programming in Java 8
  6. Backports

Advantages of Java 9

  1. Language Updates
  2. Concurrency
  3. Modularity
  4. JShell

Java 10 and 11

  1. Local Variable Types
  2. Lambda Expression Local Variable Types

Java 12-21

  1. Release Dates
  2. Preview Features
  3. Switch Expressions
  4. Records
  5. Multiline Strings
  6. Pattern Matching Instanceof
  7. Virtual Threads
  8. Part II: The Java Ecosystem

Ecosystem Overview

  1. Continuous Development and Testing

Maven

  1. What is Maven?
  2. Using Maven
  3. Starting a New Project
  4. Lifecycle
  5. Dependencies
  6. Properties
  7. Maven the Complete Reference
  8. Executing Code
  9. Deploying to Maven Central

JUnit

  1. What is JUnit?
  2. Hamcrest
  3. Assumptions
  4. Parameterized Tests
  5. Value Source and Arguments

Utilizing Essential Libraries

Logback

  1. Using SLF4J
  2. Configuration
  3. MDC

Hibernate

  1. Starting Out
  2. Mappings
  3. HQL
  4. Configuration
  5. Find out More

Guava

  1. Collections
  2. Objects
  3. Concurrency
  4. Functional Programming
  5. Optional
  6. Other Useful Classes

Modern Java Concurrency

  1. State of Concurrent Programming in Java
  2. Prominent Models for Concurrency
  3. Synchronize in Java
  4. Java Futures
  5. STM in Clojure
  6. Actors
  7. Groovy GPars

RxJava

  1. Flowable
  2. Parallel Computing
  3. Schedulers
  4. Publishers
  5. Hot and Cold
  6. Backpressure
  7. Part III: JVM Languages

Other JVM Languages

  1. Why use non-Java Languages?
  2. Polyglot Programming
  3. Edge-Craft
  4. Java.next(): Groovy vs. Scala

Groovy

  1. What is Groovy?
  2. Compact Syntax
  3. List and Map Definitions
  4. Easy Properties
  5. GString
  6. String
  7. Closures
  8. Return Optional
  9. A Better Switch
  10. Gotcha’s
  11. Command Chains
  12. Modules
  13. Static Type Checking
  14. Invoke Dynamic Support in Groovy

The Groovy Ecosystem

  1. Web and UI Frameworks
  2. Cloud Computing Frameworks
  3. Build Frameworks
  4. Testing Frameworks/Code Analysis
  5. Concurrency
  6. Others

Gradle

  1. Getting Started
  2. Projects and Tasks
  3. Plugins
  4. Configuring a Task
  5. Extra Configuration
  6. Maven Dependencies
  7. Gradle Properties
  8. Multiproject builds
  9. File Operations
  10. Exploring
  11. Build Scans
  12. Summary
  13. Online Documentation

Spock

  1. Introduction
  2. A Simple Test
  3. Mocking
  4. Lists or Tables of Data
  5. Ranges
  6. Expecting Exceptions
  7. Conclusion

Scala

  1. What is Scala?
  2. Hello World
  3. Everything’s an object
  4. Everything’s an expression
  5. Match is Switch on Steroids
  6. Traits as Mixins
  7. List and Apply
  8. Tuples
  9. Maps
  10. For Expressions
  11. A Brief History of Scala
  12. Conclusion

The Scala Ecosystem

  1. Web Frameworks
  2. ORM Frameworks
  3. Build frameworks
  4. Testing frameworks/Code Analysis
  5. Concurrency
  6. Part IV: The Web

RESTful

  1. REST in Groovy
  2. REST in Scala
  3. JAX-RS 1.0
  4. JAX-RS 2.0

Microservices and Clouds

  1. Microservices
  2. OSS
  3. More Information
  4. JVM Clouds

Grails

  1. What is Grails?
  2. Quick Overview of Grails
  3. Plugins
  4. REST in Grails
  5. Short History of Grails
  6. Testing
  7. Cache Plugin
  8. Grails Wrapper
  9. Cloud
  10. Only an Overview

Spark

  1. Getting Started
  2. Routes
  3. Filters
  4. Sessions, Cookies, and More

Spring Boot

  1. Gradle Plugin
  2. SpringBootApplication
  3. Auto-Cofiguration
  4. Actuator
  5. Rest Controller
  6. Devtools
  7. Conclusion

Play Framework

  1. What is Play?
  2. Quick Overview of Play
  3. Controllers, Views, Forms
  4. ORM
  5. Play 1.x
  6. Play 2.0
  7. Getting Started
  8. Only an Overview

Ratpack

  1. Script
  2. Java Main
  3. Gradle
  4. Ratpack Layout
  5. Handlers
  6. Rendering
  7. JSON
  8. Bindings
  9. Blocking
  10. Configuration
  11. Testing
  12. Summary

Final Thoughts

  1. The State of the JVM
  2. The Future
  3. Contact the Author

Appendix: Groovy for Java Devs10

Appendix: Scala for Java Devs11

Java 8 Cheatsheet

  1. Lambda Syntax
  2. Method References
  3. Functional Interfaces under java.util.function

Contact the Author

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

Causes

Causes Supported

Electronic Frontier Foundation

Electronic Frontier Foundation

Defending your civil liberties in a digital world.

https://www.eff.org/
Based in San Francisco, EFF is a donor-supported membership organization working to protect fundamental rights regardless of technology.
From the Internet to the iPod, technologies are transforming our society and empowering us as speakers, citizens, creators, and consumers. When our freedoms in the networked world come under attack, the Electronic Frontier Foundation (EFF) is the first line of defense. EFF broke new ground when it was founded in 1990—well before the Internet was on most people's radar—and continues to confront cutting-edge issues defending free speech, privacy, innovation, and consumer rights today. From the beginning, EFF has championed the public interest in every critical battle affecting digital rights.

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub