Java Articles

Java 8 Example – Lambdas

A few months ago I wrote about how our core Java courses are being updated to Java 8.  Now that the updates are a little further along we also have a course map that can show which Java 8 courses we have might be appropriate for you.  You can find that here:

Java Course Map

I thought that it might be good to offer a quick example of some of the things in Java 8 on our blog.  Since you can’t really talk about Java 8 without discussing Lambda expressions I figured I would start there.

Read the rest of this entry »

No Comments

Simple Algorithms for Effective Data Processing in Java

The needs of Big Data processing require specific tools which nowadays are, in many cases, represented by the Hadoop product ecosystem.

When I speak to people who work with Hadoop, they say that their deployments are usually pretty modest: about 20 machines, give or take. It may account for the fact that most companies are still in the technology adoption phase evaluating this Big Data platform and with time the number of machines in their Hadoop clusters would probably grow into 3- or even 4-digit ranges.

Development on Hadoop is becoming more agile with shorter execution cycles — Apache Tez, Cloudera’s Impala, Databricks’ Spark are some of the technologies that aid in the process along the way.

Read the rest of this entry »

No Comments

Java Courses Being Updated to Java 8

UPDATE – In order to provide clients a choice on which Java version they would like training on, we are releasing new course codes for Java 8.  Our current course codes will stay at Java 7 for those that need that version.

At Web Age Solutions it is important for us to make sure we are offering training that is relevant and appropriate for you.  Even though Java SE 8 was released some time ago, clients have taken a while to start using it since most Java environments they ran applications in had not yet added Java 8 support.  With the latest versions of all major Java EE application servers offering some type of Java 8 support that dynamic has changed.

We are updating our primary Java training courses to add Java 8 coverage.  The primary courses being updated are:

WA2494 Introduction to Java 8 Using Eclipse

WA2509 Advanced Java 8 Using Eclipse

The following courses will remain available using Java SE 7 for clients that need this version.

WA1278 Introduction to Java Using Eclipse

WA1449 Advanced Java using Eclipse

Since we know that there are also lots of Java programmers that do not need to take a “standard” course but simply need to learn what the changes are with this new version, we are also releasing a new course that covers the most recent changes.  This course covers the major changes of Java 8 that will have a significant impact on a wide range of Java applications in addition to a few important Java 7 features that are well known.

WA2493 What’s New in Java 8

So what is new in Java 8?  Will it impact your applications?  Java 8 is one of the most significant updates to Java in some time.  After Oracle bought out Sun, Java 6 was around for quite a while.  Oracle decided to release the "easy stuff" in Java 7 while working on some of the more significant changes for Java 8.

While the following is not an exhaustive list of Java 8 changes (you can go here for that) the following are some of the major features that are likely to impact a large cross-section of Java applications.

  • Lambda Expressions – This is by far the most impactful change in Java 8.  A “Lambda Expression” allows for the definition of an anonymous function that can be used as an object, for example being passed as a method parameter.  Besides simplifying code by replacing many usages of anonymous classes, a wide range of features are available as the rest of the Java platform was examined to use Lambda expressions where they made sense.
  • Collections Stream API – One place where Lambda expressions is leveraged is the Collections “Stream API”.  This lets you perform aggregate operations on a collection of objects.  For example, you might want to search through a set of CustomerProfile objects for all of the ones in a certain zip code and age range.
  • New Date/Time API – Although Java has always had the concept of ‘Date’ to represent a moment in time, many date and time related operations have been difficult.  Even answering the simple question “What was the date of the first Monday in November last year?” would be very complex.  The addition of the Date/Time API in Java 8 is meant to provide standard tools for these kinds of use cases.  This has long been a need in Java and now you won’t need third party libraries to address this need.
  • Concurrency changes – Although Java concurrency is not new, Java 5 and Java 7 introduced significant features in this area.  Java 8 continues to expand this area of Java programming, of particular importance since the impact of efficiently using multiple CPU processors, for example, can realize a significant improvement in performance.
  • Default methods – Currently, if you want to change the API of an interface, any implementing class is forced to implement the new functionality.  With Java 8 “default methods” you can add a new method to an interface along with a “default” implementation.  This implementation would be used for older classes that implement the interface but do not provide a unique implementation of the new method.  This could help you add new functionality to systems while minimizing the impact on existing, and already proven, libraries.

As I mentioned this is nowhere near absolutely all of the new changes in Java 8 but certainly most of the most significant. 

Besides the above courses that are being updated and released, we will also soon have a webinar that covers some of these changes as well.  Keep an eye on our webinar page for when that is scheduled.

No Comments

WebSphere Liberty Profile Webinar – Wednesday, May 28, 2PM Eastern

Although WebSphere Application Server is one of the most robust Java Enterprise Application Servers for deployment of mission critical applications, it is not always that easy to use in development. Often we see clients who deploy to WebSphere in production using Tomcat or some other server to test in development because it is "easier". The complaint is that the full WebSphere Application Server takes too long to start or redeploy applications and is not intuitive to configure for developers. To address these issues, IBM has created the WebSphere "Liberty Profile" server. This is a lightweight server, certified for Java EE 6, that starts much faster and is easier to configure.

 

In this webinar we will look at the features of the WebSphere Liberty Profile server, how it compares to the "full" WebSphere Application Server, and how you can use it to simplify the development and testing of Java EE applications. We will even show that with version 8.5.5 of the WebSphere Liberty Profile there are some intriguing new features that would even let you run the server as part of a cluster and use it for some production deployment scenarios. We will also highlight the use of FREE Eclipse development tools that are available since the cost of development tools for WebSphere Application Server has also been historically an issue.

 

Register for the webinar here

No Comments

Time for Spring …. 4!

On the first day of Spring 2014 (even though some of you may feel winter will never end) I think it is a good time to talk about what is going on with the Spring Java Framework.

Over the past year there have been some big things going on with Spring, probably the chief among them the move in April 2013 to place Spring under the control of the new company GoPivotal.  This spin-off from VMware, along with an investment from GE, is meant to support a new breed of applications where cloud and big data are a given not some afterthought on a platform not built for it.  With the ever-expanding broad ecosystem of Spring-related projects, in addition to the immense popularity of the core Spring Framework, Spring seems a natural fit as an application framework to support this.  Probably the most immediate change for those already using the Spring Framework day to day though was that there was a new web site to get Spring documentation, downloads, resources, etc:

http://spring.io/

Fast forward to the end of 2013 and we had the release of the Spring 4 Framework in December.  The release of Spring 4 fits nicely with the desire to support more modern applications as support for many new technologies has been added.  Among those are included support for Java EE 6 & 7, Java SE 8 (which was just released) and more recent versions of many optional third party libraries.  Spring 4 is also a new foundation for the expanding list of Spring-related projects, the following just a few key ones to mention now:

  • Spring Boot – Jumpstart on rapid development of Spring applications
  • Spring Data – An umbrella project with a number of useful utilities for popular data access technologies like MongoDB, Hadoop, and JPA
  • Spring XD – Unified system for big data ingestion, analytics, batch processing and export
  • Spring Security – Application security framework
  • Spring Mobile & Spring for Android – Support for developing mobile applications
  • Spring Integration – Implementation of well-known enterprise integration patterns
  • Spring Batch – Comprehensive batch application framework
  • and several more

As you start to look at the Spring 4 Framework and what it can do for you, we at Web Age Solutions would like to assist you in that discovery.  Below are some links to a webinar we will be giving next week on the changes in the Spring 4 release and a link to the new training category we have posted with Spring 4 training classes.

WEBINAR – What’s new in Spring 4, Thursday March 27th 1:30-2:30 PM Eastern

TRAINING CLASSES – Spring 4 Framework Training Classes

Here’s to hoping that your wait for using Spring 4 will not be as long as the wait for Spring 2014 has seemed!

,

2 Comments

Building a Bi-Directional Event Bus with the Google Guava

The Google Guava is an open-source project released under Apache License 2.0 (a very permissive one) that bundles several core Java libraries used by Google software engineers in their projects.  The Guava library is packed with powerful utilities and efficient helper classes that aim at making the lives of Java programmers easier and their work more productive.

Generally, Guava offers a more facile way to interact with some of the existing Java language constructs as well as fills in a number of gaps that exist in the language.

For example, shown below is a piece of code that you need to write in order to create a dynamic proxy for some interface Foo using the regular Java constructs:

Foo foo = (Foo) Proxy.newProxyInstance(
Foo.class.getClassLoader(), new Class<?>[] {Foo.class}, handler);

While for some it may be perfectly fine to write code like this and they do write code this way as they believe that “Where there’s muck there’s brass”, others would argue that there is a great deal of unnecessary noise in the above code where after all the pain of getting your ducks in a row in the newProxyInstance() method, you are still forced to do downcasting to Foo.

In the Hakuna Matata world of Guava, the ugly-looking legacy Java Proxy construct (circa Java 1.3) gets hidden under the generified user-friendly API:

Foo fu = Reflection.newProxy(Foo.class, handler);

This Guava construct also enforces type-safety at design-time making casting superfluous as the type of the Lvalue (fu) is inferred from the first parameter passed to the newProxy()method (Foo.class).

That’s what SpringSource has always been so good at: shielding developers from the internal complexity of various systems with their user-friendly API.  They treat developers as valuable clients of their APIs.

Read the rest of this entry »

3 Comments

Testing Cordova Hybrid Apps in Worklight

Recently I worked on a project that introduced me to IBM® Worklight® mobile application platform. Among other things, I was pleasantly surprised at the price tag of the Developer Edition of this product: it is free. The Developer Edition comes with an Eclipse-based IDE called the Worklight Studio which offers support for authoring the client-side of your mobile web, hybrid and native apps as well as developing server-side components called adapters.

The Worklight Studio comes with a web application called the Mobile Browser Simulator that can help you with developing and testing your hybrid applications created using Apache Cordova framework. The Mobile Browser Simulator offers you a suite of visual controls for simulating a variety of native bridge APIs to such native device capabilities as accelerometer, camera, compass, file system, device info, contacts database, etc., without the need to run your apps directly on mobile devices or their emulators (which would require setting up specific run-time environments, such as ADT Eclipse plug-in for Android, Xcode for iPhone, etc.)

Here is a screen-shot of the Mobile Browser Simulator that shows Cordova APIs’ visual controls/widgets on the left with the expanded Battery widget that helps simulate different battery levels and the battery plugged-in event (fired when the battery is plugged in for charging and stays in this state until un-plugged).
Worklight 6.0 Mobile Browser Simulator Screen

So, if you are interested in this approach to testing Cordova hybrid apps, below are a few simple steps to follow that will help you get up and running in no time.

Note: For this blog posting, I used Worklight ver. 6.0 which comes with Cordova framework ver. 2.6.
Read the rest of this entry »

1 Comment

Java EE 8 and beyond

Every new release of the Java EE platform makes it incrementally better by adding new features or simplifying its interfaces which was also the main theme of the latest Java EE ver. 7 release (Oracle press release can be found here).

Let’s review some of the aspects of the new release and touch on the subject of the platform’s potential growth vectors.

 Reduce the boilerplate code.   Is the mission finally accomplished?

One of the repeated topics in each and every Java EE release since version 5 has been “reducing the boilerplate code”.  And it looks like that with the help of meta programming facilities offered by annotations and Contexts and Dependency Injection (CDI) capability introduced in JEE6, this goal has been practically achieved. The latest beneficiary of this exercise is JMS that in EE7 underwent a major overhaul.  The incidental complexity of JEE programming has been reduced to the point beyond which it would require something conceptually similar to emoticons to make it even simpler.  As the old adage goes: “Make things as simple as possible, but not simpler.” So there is probably not too much to expect (or demand) in this department in future releases …

Caching

Java in-memory caching API (JCache) did not make it to the final release of Java EE7 and is likely to be included in the JEE8 release.  Not a big deal for those Java developers who know that they can always plug in ready-to-use in-memory cache solutions for Java objects such as the open-source Ehcache product (which is a version of the JCache specification as implemented by Terracotta).

More support for web technologies

JEE7 now offers support for a wider range of web technologies, such as HTML5, WebSockets, and JSON all of which will consolidate its position as a feature rich modern web server platform.  This is a big thing, no doubt.

Currently, JEE already has the servlets, JSPs, JSFs, and facelets with the overall trend toward increased sophistication of Web tier programming which is directly correlated with its growing complexity.

To reduce complexity of Web tier development and potentially draw additional interest in the platform, a move in the opposite direction – toward simplified Web programming models in JEE – may be a viable alternative.  Scripting support from web-aware components like Groovlets or the like may fit the bill.  Another area to explore could be simplified access to business logic via an AJAX-based bridge between JavaScript (or any other browser scripting language that may become popular in future, like Dart and Java modules.  Currently, there are quite a few Java Web Remoting frameworks such as DWR,  Apache Tuscany project (to some extent), and Google Web Toolkit, that can be used as a starting point for the analysis of such systems.

Embracing techniques and ideas from open source projects

Java EE has started to more willingly embrace proven techniques and ideas conceived and developed outside of the realm of Java EE specs.  Under this trend, JEE can effectively (and efficiently) leverage the know-how used in developing systems that are already enjoying a wide adoption in the Java community.  An example of this would be the Contexts and Dependency Injection (CDI) capability built on top of the ideas and concepts underlying the popular Spring and Guice dependency injection systems as well as the Seam context management framework.

Now, without much ado, JEE7 fast-tracked the Batch Processing spec based on the Spring Batch framework (batch jobs are tasks that can be executed without user interaction, such as ETL scripts, etc.).

Support for NoSQL Databases

NoSQL databases are on the curve of gradual adoption in the Enterprise world and this is one of the areas where JEE can take a big piece of the action.

One of the models to emulate is SpringSource’s Spring Data umbrella project that offers Spring-powered data connectors to NoSQL databases, map-reduce frameworks, and cloud-based data stores.

EIS vendors, who wish to expose functionality of their products to the JEE platform in a “standard JEE” way, are always welcome to create JCA-compliant resource adapters for their products thus lending credibility (in the eyes of some conservative executives) to their NoSQL solutions.

This activity needs to go along with an effort to standardize a “NoSQL language” (if one is ever accepted by the very diverse NoSQL database community).  Unstructured Query Language (UnQL) project is a step in this direction.
Read the rest of this entry »

No Comments

Create Better Web Applications With Java EE 6 Training

At Web Age Solutions, we have the challenging task of not only keeping up with technology specifications but whether clients are actually using those technologies.  We have started to see much more interest in Java EE 6 training on various platforms so this is obviously taking hold.

Java EE 6 had the unenviable distinction of being released pretty much right as companies were trying to dig out of the 2008-2009 economic downturn.  So even though it did take 1-2 years for all of the major server platforms to release versions that supported it, many clients were taking a “wait and see” approach to upgrading.  Since companies first have to upgrade to the most recent platform before they can even think about using the new technology that is available it has taken until now to really start seeing that take hold.  Even JBoss clients, which usually take a more “figure it out on our own” approach, are doing training to make sure they can fully take advantage of the latest JBoss version, including the very different administration model (which we cover in our WA2060 JBoss Administration and Clustering course).

One of the primary barriers to taking advantage of what the new platform can do is simply knowing what is available.  Quite often projects take an approach of “we do it this way because we’ve always done it this way” and don’t look for ways to improve and simplify their applications by leveraging new approaches to programming.  With Java EE 6 (and soon Java EE 7) continuing to expand the possibilities that are out there this is becoming more of an issue.  We are a long way from the days when only Servlets/JSP were “standard” and you needed a thick “patterns” book just to create your own web framework.

To further support those that might be looking for Java EE 6 training, I’ve updated all of our course maps for Java EE 6 training on the major platforms.  These course maps show a different path depending on if you are familiar with the big changes introduced in Java EE 5 since several clients often skip versions of a server and in particular we are seeing migration paths like WebSphere 6.1 –> WebSphere 8.x.  These course maps also mention some of the Spring 3 training classes we offer since clients sometimes do training in that area as well.

Java EE 6 Course Map for WebSphere 8.5

Java EE 6 Course Map for WebSphere 8.0

Java EE 6 Course Map for WebLogic 12c

Java EE 6 Course Map for JBoss

Looking to the future, the Java EE 7 specifications are finalized and servers are being updated right now to fully support them.  JBoss is as well and will probably be released early next year (they say this year but JBoss is always missing release deadlines).  The tricky thing is that the open source project is being renamed to “Wildfly” and the “JBoss” name will be reserved for only the supported version.  There is already a version mismatch between the two and now having two different names I think is going to cause more confusion but we will see.

As servers release support for Java EE 7 I think the goal is to try and release classes as early as possible.  This will depend somewhat of course on which servers release support first.  We are going to be working internally to develop ways where we can develop hands-on labs that are more modular and can be more easily reused in different courses so we can start developing those early and support more clients that are “early adopters” and want to upgrade quickly.  Java EE 7 contains a lot of updates as well so we are looking forward to introducing that to clients as they start moving to servers that support it!

Now we get to sit back and enjoy watching the “race” of which server supports Java EE 7 first.  Any bets?

No Comments

Accessing EJBs from Java SE Using WebSphere’s Embeddable EJB Container

Introduction

In this blog, we’ll explore how to employ the Embeddable EJB Container inside a Java SE application using WebSphere Application Server 8.x.

Embeddable EJB Container

One of the new features introduced in EJB 3.1 (part of Java EE 6) is the Embeddable EJB Container. The main two use cases for the Embeddable EJB Container are:

  1. Unit testing your EJBs without requiring a Java EE application server
  2. Embedding EJBs inside a Java SE application, which allows you to take advantage of their benefits (e.g., security and transactions)

The primary advantages of using the Embeddable EJB Container are:

  • You don’t need to install the application server if all you need to do is unit test or employ your EJBs within a Java SE-based application. You just need access to the vendor’s Embeddable EJB Container JAR file.
  • The Embeddable EJB Container starts almost instantaneously, unlike the server-based EJB container (which can take a minute or more to start up), since the Embeddable EJB Container initializes only EJB-related components.
  • The Embeddable EJB Container has a much smaller memory footprint than the equivalent server-based EJB container.

Read the rest of this entry »

1 Comment