Skip to content
Ken Kousen edited this page Aug 10, 2022 · 5 revisions

Java Upgrade Course

Safari Books Online, https://www.safaribooksonline.com/

This document is for notes that come up during class. It’s also an easy way to share code and other materials.

You need Java 8 or above for this course. The repositories all have been tested under Java 11 (OpenJDK 11.0.1).

Java Is Still Free link (post on Medium):

Import GitHub repository into IDE

IntelliJ

Import the build.gradle file

  1. Use Open if an existing project is open, or Import otherwise

  2. Navigate to the build.gradle file in the root of the project

  3. Accept all the defaults in the Import wizard

Eclipse

Create an Eclipse project and import it

  1. From a command prompt, execute >gradlew cleanEclipse eclipse

  2. Use File → Open → General → Existing Projects Into Workspace → navigate to the root of the project and select it

Setting a Gradle proxy (if necessary)

If you have a proxy to configure, create a file called gradle.properties in either the project root directory or in ~/.gradle (create that folder if necessary) and add:

systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost

systemProp.https.proxyHost=www.somehost.org
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=userid
systemProp.https.proxyPassword=password
systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost

Java Updates since 1.8:

Java 9 added Java Platform Module System (JPMS)

See Jigsaw docs at OpenJDK: http://openjdk.java.net/projects/jigsaw/

Java 10 added Local Variable Type Inference (LVTI)

Additional topics (if time available)

(Some are on the outline, but some aren’t)

  • Optional

  • File I/O

  • Lazy streams

  • Deferred execution

  • The peek method

  • Boxed streams

  • map vs flatMap

  • Closure composition

  • The reduce method

  • Exception handling

  • Partitioning and grouping

  • Downstream collectors

  • The java.time package

Parallel streams

For parallelization to be beneficial:

  • Either a lot of data, or a process that takes a lot of time per element

  • Data that is easy to partition

  • The operations must be stateless and associative

Java streams by default use a ForkJoinPool whose size matches the number of processors.

References

Note
Links are given for Safari Books Online when available.

Books