Java 8/9/10 and later

The new features of Java 8/9/10/... such as lambda, data-streams, modules

Java version 8, introduced three concepts that changed the way we write code within the methods of a class. These are Lambda Expressions, Data Streams and Asynchronous Computation.

Java version 9, introduced another game-changing way of working with its new module system (JPMS). It allows one to design robust sub-systems with declarative dependency structure and elimination of class-not-found JVM errors.

This course appeal to Java developers that have been working with older versions of Java and would like to get up to speed with applying all new features of Java.

This is what you will learn
  • Write Java programs using lambda expressions
  • Write Java programs using data stream pipelines (Stream<T>)
  • Write Java programs using asynchronous tasks (CompletableFuture<T)
  • Using the new classes dealing with dates, time-points and durations
  • Design Java applications based on (JPMS) modules
  • Understand modules and dependency links
  • Create a dedicated and shrink-wrapped JRE for a single Java application using jlink
  • Implement interfaces with private methods
  • Implement a pipeline of (forked) OS processes
Course Contents

The Java Time-Line

  • Language evolution
  • New Java version twice a year

JShell - The Java REPL

  • What is JShell
  • Usage
  • Built-in commands
  • Understanding snippets
  • Using jshell from within a Java program

Functional Interfaces

Functional interfaces is a syntactic foundation for lambda expressions covered in the next chapter. Here we discuss what it is and other syntactic enhancements of interfaces in Java to support the introduction of lambda expressions.

  • Functional interface
  • Default method
  • Method and constructor reference
  • Functional interfaces in the Java API

Lambda Expressions

Lambda expressions (aka closures or anonymous functions) is a much welcome addition to the Java syntax and the fundamental building block on virtually almost everything else we cover in this course.

  • What is a lambda expression (aka closure)
  • Basic syntax
  • Dealing with free variables
  • Limitations of the type system
  • Currying

Java API Class Update

Of course, have all the collection classes been augmented to support lambdas. Here we walk you through the changes both for collection classes and others as well.

  • Review of the most important container classes
  • Lambda oriented methods in the collection classes
  • Optional
  • The Java 8 API explorer

Data Streams

Java has always been about data-structures and its organization. What you did inside the method of a class was left to your discretion, until now. Say hello, to data streams. After you have seen the merits of writing functional code as a pipeline chain of filters, transformations and aggregators, you will never go back. Trust us on this.

  • What is stream and pipeline
  • Stream sources
  • Bounded and unbounded streams
  • Number streams
  • Parallel streams
  • Filters and matchers
  • Mappers and aggregators
  • Numeric aggregators
  • Understanding collect()
  • Understanding reduce()
  • Using the Collectors utility
  • Special filters
  • Using Map and FlatMap
  • Sorting and shuffling
  • The Java 8 Streams Cheat Sheet

Date and Time

First we had java.util.Date, with its millennium bug problem. Then came java.util.Calendar as a mere overkill and then nothing for two decades. Finally, java.time has arrived as a proper solution for dealing with time, date, duration and time-zones.

  • Clock
  • ZoneId
  • Instant
  • LocalTime och LocalDate
  • Factory methods
  • Builders

File I/O

Overview of java.nio classes. Most of them was introduced before Java 8, but many has then been updated to support lambdas ans streams processing.

  • Concepts and abstractions in java.nio
  • File systems support
  • Understading Path
  • Useful utility classes, such as Files and Paths

Threaded Computation

Short overview of how the threading support has evolved in Java and a motivator and background for the next chapter.

  • Execution models
  • What is a thread
  • Concurrency problems to bw aware of
  • Thread-safe data-structures introduced in Java 5
  • Using thread-pools (aka Executors)
  • Usage of interface Callable<T>
  • Understading and using Future<T>
  • Fork/Join concurrency introduced in Java 7
  • Using jSoup to scrape HTML pages and different ways of running several scraping tasks in parallel

Asynchronous Computation

Asynchronous computation has over the last half-decade emerged as the most important computation paradigm, because of how efficient it handles system resources and scales way beyond threaded computation. In this chapter you will learn all you need to know in order to write you own asynchronous computation chains using the new CompletableFuture<T> class. We will also show you how to combine Stream<T> with CompletableFuture<T>.

  • Limitations of threaded computation
  • What is asynchronous computation
  • Limitations of Future<T>
  • Using call-back functions
  • Limitations of the call-back model
  • The boomerang effect
  • Interface CompletionStage<T>
  • Class CompletableFuture<T> and what it does
  • Time capped computation using a promise
  • Creating an async stage using supplyAsync()
  • Asynchronous stage chains
  • Delayed computation
  • Transforming data in a stage chain using thenApply()
  • Composing chains using thenCompose()
  • Combining chains using thenCombine()
  • Waiting the completion of many stage chains
  • Using Stream<T> to assemble partial results in an async stage chain
  • Transforming and handle exceptions
  • Running async stages in a thread pool, aka parallel computation
  • Understanding the *Async() suffix

Modules

  • What is modules in Java 9 (JPMS)
  • Changes to your source code directory organization
  • The module-info descriptor
  • Overview of the sub-divided Java API into modules
  • Changes to the JDK install directory
  • Developing a small multi-modules application
  • JUNit5 test suite
  • Project directory content
  • Execution on the command-line, using the java command
  • How to create module JAR files
  • How to make a module JAR file "executable"
  • Execution based on module JARs
  • Complete shell-script for compilation, packaging and execution
  • Listing dependencies with jdeps
  • Creating a shink-wrapped JRE using jlink
  • Executing a Java applicaiton based on a shrink-wrapped JRE
  • JMOD, a new archive file format

OS Processes

  • Obtaining meta-data for native processes
  • Listing native processes
  • Creating a communicating pipeline of native processes
  • Improved syntax for auto-closable try-statements

JVM Improvements

  • Contents of the JDK 9 installation directory
  • Multi-release JAR files (MRJAR)
  • What is the G1 gc and how does it differ from classical gc algorithms
  • GC settings removed
  • Obsolete tools
  • New way of generating JNI C++ headers

Highlights of Java 10

  • Say hello to var
  • Other changes
Facts
NameJava 8/9/10 and later
Duration 3 Days
Level Intermediate
AudienceJava programmers
Prerequisites Practical knowledge in Java programming
Tools
  • Java JDK, version 10+
  • JetBrains IntelliJ IDEA
Price19 000 kr + moms 19000
Course Dates
DatePlace
Loading course dates...
Same-Company Discout

We offer a 20% discount for additional participants from the same company and at the same course date. Read more here.

On-Site Course

If you order an On-Site course, we will come to you and hold the course in your office. The price is determined by our price model and is based on the number of course days, number of participants and any travel and lodging.

Read more about out price modell and term of sales here.

Related Courses
CourseDaysLevel
Java Basics5 BeginnerShow
Java Intermediate3IntermediateShow
Java Threads and Concurrent Programming2AdvancedShow
Java for REST Web Services Apps2 Intermediate Show