Version 8 (LTS) -2014-03
Usage from sdkman
sdk install java 8.0.302-open
- installsdk use java 8.0.302-open
- use in current shell
Compact Profiles [JEP 161]
- EJDK - Embedded JDK
- 🔗 Introducing the EJDK
- 🔗 Exploring jrecreate
jrecreate
- can create different JVM profiles.
javac -profile <profile>
- compiles for a specific profile.
Lambda Expressions and the stream API [JEP 126]
Date & Time API - 🔗 java.time
[JEP 150]
Described in [Java SE 8 for the really impatient] chapter 5.
All objects are immutable.
A few notes on date and datetime used in programming is found in Usage of Dates and Times in Networked Applications
Instant
- a point in time.Duration
- a time based amount of time. The difference between twoInstant
’s. See DurationTest for an example of measuring the duration of an operation.Period
- a date based amount of time. Use this when working with calendar days.- Types without time zone:
LocalDate
- a date without a time. This stores a date like ‘2010-12-03’ and could be used to store a birthday.LocalDate today = LocalDate.now(); LocalDate someday = LocalDate.of(1969, Month.JULY, 16);
LocalTime
- a time without a date. This stores a time like ‘11:30’ and could be used to store an opening or closing time.LocalDateTime
- stores a date and time. This stores a date-time like ‘2010-12-03T11:30’.
ZonedDateTime
- date time with time zones. Use this if you need to account for daylight changes.java.time.temporal.TemporalAdjusters
- static methods for returning different adjusters of dates. E.g.next(TUESDAY)
orlastDayOfMonth
. See examples in TemporalTest.java.time.format.DateTimeFormatter
- static formatters for formatting date and time. E.g.ISO_LOCAL_DATE
. Specific instances can be created by usingDateTimeFormatter.ofPattern("yyyy-MM-dd")
. All DateTime objects has aformat()
and aparse()
method that takes aDateTimeFormatter
as argument.java.time.chrono
-package - calendar systems for other systems than the Gregorian calendar. Supported systems:- Hijrah calendar - the Islamic calendar
- Japanese calendar
- Minguo calendar - the calendar in Taiwan
- Thai Buddhist calendar - the calendar in Thailand
See ChronologyTest for an example of the current date in these calendars.
java.util.Base64
encoder and decoder
Base64 encoders and decoders for:
- basic format (RFC 2045)
- URL encoding (RFC 4648)
- MIME encoding (line break every 76’th character)
See examples in Base64Test.
JNI - Statically linked libraries [JEP 178]
- TODO
Project Nashorn - javascript runtime [JEP 174]
- replaces Rhino
- 🔗
javax.script
- 🔗
jrunscript
- command line script shell that supports multiple scripting languagesjrunscript -q
- lists the supported script engines- supports both REPL mode and running of script files
- deprecated in java 11
Garbage Collectors
- removal of the Permanent Generation [JEP 122]
HotSpot Virtual Machine Garbage Collection Tuning Guide, release 8 (🔗 original link)