Category Archives: Java 8


What are the new features introduced in JAVA 8?

There are dozens of features added to Java 8, the most significant ones are mentioned below :-

Lambda expression − Adds functional processing capability to Java.

Method references − Referencing functions by their names instead of invoking them directly. Using functions as parameter.

Default method − Interface to have default method implementation.

New tools − New compiler tools and utilities are added like ‘jdeps’ to figure out dependencies.

Stream API − New stream API to facilitate pipeline processing.

Date Time API − Improved date time API.

Optional − Emphasis on best practices to handle null values properly.

Nashorn, JavaScript Engine − A Java-based engine to execute JavaScript code.


What’s new in Java EE 8?

The Java Community Process machinery has started increasing on Java EE again, a little over a year after Java EE 7 was released. The main aim is to create the next major version of Java Enterprise Edition.

This release is going to build upon the highly successful previous release of the platform, with the addition of many new functionalities. Some JSRs that could not be included in the last release, principally because of scheduling constraints, and that are now targeted to be included in Java EE 8. So, let’s dive deep in and see what are the key themes for the release.

Support for latest Web standards such as, HTML5 server-sent events, standardized binding between JSON text and Java objects, HTTP/2 support, action-based MVC, updates to Java API for WebSocket, and JSON Processing.

Some features, such as HTTP/2, action-based MVC, and JSON Binding, are fairly big additions to the platform and are filed as separate JSRs.

Further simplification of the programming model by CDI alignment across the specs. Today declarative security and @Schedule can only be specified on enterprise JavaBeans. This is targeted to be made more generically available for POJOs. There are some unique features to EJB such as remoting, concurrency, and pooling that would need to be extracted and applied more widely to POJOs. JAX-RS has a few areas where clean-up is required such as CDI alignment, server-side async, and simpler hypermedia API. Older EJB 2-style APIs and CORBA IIOP interoperability are also targeted for pruning.

Infrastructure for cloud support Basic support for cloud infrastructure was added in Java EE 7, such as schema generation in JPA 2.1 and resource library templates in JSF 2.2. This addition will make flexible configuration of applications such as multi-tenancy and simplified security. REST-based APIs for management and monitoring will allow building a customized dashboard which is portable across different application servers.

Java SE 8 alignment: Java SE 8 has introduced many new features such as repeating annotations, lambda expressions, the Date/Time API, type annotations, and CompletableFutures. Component JSRs will be encouraged to take advantage of these features. For instance, @DataSourceDefinitions, @JMSConnectionFactoryDefinitions, @MailSessionDefinitions, and other similar annotations can be deprecated in favour of repeating annotations. Expression language is the added support for Lambda expressions, initially due to Java EE 7 and JDK 8 schedules not aligning. This support would need to be replaced with a JDK 8 standard now.


JSR 371:

  • Leverage existing Java EE technologies.
  • Model should leverage CDI and Bean Validation.
  • View should leverage existing view technologies like JSPs and Facelets.
  • Defining a new template language is out of scope, existing languages such as Freemarker, Velocity, and others should be evaluated.

JSR 367:

    • There is only standard way to convert JSON into Java objects and vice versa.
    • JSON-B will leverage JSON-P and provide a conversion layer above it.
    • A default mapping algorithm will be defined for converting existing Java classes to JSON. The default mappings can be customized through the use of Java annotations and will be leveraged by the JSON-B runtime to convert the Java objects to and from JSON.

JSR 365:

  • Split CDI into two parts: 1. Core CDI programming model and 2. Java EE integrations for CDI.
  • Overhaul thread-bound request-response context model, allows the application or container to portably and push the active context to CDI when it requires the use of CDI.

JSR 369:

Expose support for the upcoming IETF standard HTTP/2 to users of the Servlet API.

  • (I) Request/response multiplexing.
  • (II) Stream prioritization.
  • (III) Upgrade from HTTP 1.1.

* Refresh the Servlet API to achieve compliance with new features.

JSR 372:

Ajax method invocation: It allows invoking CDI managed bean methods directly from Ajax, allowing the response to be sent using standard JSON.
Better integration with Java EE 8 and Java SE 8.

JSR 375:

The goal is to simplify, standardize, and modernize the Security API across the platform. There is a proposal to simplify managing users and groups. Also, improvements related to password aliasing, role mapping, authentication and authorization with CDI support.

JSR 380:

The main aim is to leverage Java 8 language constructs, such as, optional’s, date and time API, and repeatable annotations.

Below is the sample code of Java EE 8:

package com.airhacks.time.presentation;

import javax.inject.Inject;
import javax.mvc.Controller;
public class TimeController {
Models models;
AtomClock clock;
public String now() {
this.models.put(“time”, new Time(clock.currentTime()));
return “/time.jsp”;

Java EE 8


Explain Java 8-Internal vs. External Iteration?

External Iterators- This Iterator is also known as active iterator or explicit iterator. For this type of iterator the control over iteration of elements is with the programmer. Which means that the programmer define when and how the next element of iteration is called.

Internal Iterators- This Iterator is also known as passive iterator, implicit iterator or callback iterator. For this type of iterator the control over the iteration of elements lies with the iterator itself. The programmer only tells the iterator “What operation is to be performed on the elements of the collection”. Thus the programmer only declares what is to be done and does not manage and control how the iteration of individual elements take place.