Friday Sep 21, 2012

Java EE 6 Pocket Guide from O'Reilly - Now Available in Paperback and Kindle Edition

Hot off the press ...

Java EE 6 Pocket Guide from 'OReilly Media is now available in Paperback and Kindle Edition. Here are the book details:

Release Date: Sep 21, 2012
Language: English
Pages: 208
Print ISBN: 978-1-4493-3668-4 | ISBN 10:1-4493-3668-X
Ebook ISBN:978-1-4493-3667-7 | ISBN 10:1-4493-3667-1

Java EE 6 Pocket
Guide The book provides a comprehensive summary of the Java EE 6 platform. Main features of different technologies from the platform are explained and accompanied by tons of samples. A chapter is dedicated to Managed Beans, Servlets, Java Persistence API, Enterprise JavaBeans, Contexts and Dependency Injection, JavaServer Faces, SOAP-Based Web Services, RESTful Web Services, Java Message Service, and Bean Validation in that format.

Many thanks to Markus Eisele, John Yeary, and Bert Ertman for reviewing and providing valuable comments. This book was not possible without their extensive feedback!

This book was mostly written by compiling my blogs, material from 2-day workshops, and several hands-on workshops around the world. The interactions with users of different technologies and whiteboard discussions with different specification leads helped me understand the technology better. Many thanks to them for helping me be a better user!

The long international flights during my travel around the world proved extremely useful for authoring the content. No phone, no email, no IM, food served on the table, power outlet = a perfect recipe for authoring ;-)

Markus wrote a detailed review of the book. He was one of the manuscript reviewers of the book as well and provided valuable guidance. Some excerpts from his blog:

It covers the basics you need to know of Java EE 6 and gives good examples of all relevant parts.
This is a pocket guide which is comprehensively written. I could follow all examples and it was a good read overall. No complicated constructs and clear writing.
GO GET IT! It is the only book you probably will need about Java EE 6! It is comprehensive, wonderfully written and covers everything you need in your daily work. It is not a complete reference but provides a great shortcut to the things you need to know. To me it is a good beginners guide and also works as a companion for advanced users.

Here is the first tweet feedback ...

Jeff West was super prompt to place the first pre-order of my book, pretty much the hour it was announced. Thank you Jeff!

@mike_neck posted the very first tweet about the book, thanks for that!

The book is now available in Paperback and Kindle Edition from the following websites:

Here is how I can use your help:
  • Help spread the word about the book
  • If you bought a Paperback or downloaded Kindle Edition, then post your review here.
  • If you have not bought, then you can buy it at and multiple other websites mentioned above.

If you are coming to JavaOne, you'll have an opportunity to get a free copy at O'Reilly's booth on Monday (October 1) from 2-3pm. And you can always buy it from the JavaOne Bookstore.

I hope you enjoy reading it and learn something new from it or hone your existing skills. As always, looking forward to your feedback!

Wednesday Dec 21, 2011

WebLogic 12c and Coherence: OTN Virtual Developer Day in Jan/Feb 2012

Oracle WebLogic Server 12c is now available for about 2 weeks. Do you know it comes with an easy-to-use zip installer ? Have you downloaded and tried it ?

An OTN Virtual Developer Day is coming to talk about the latest and greatest features in WebLogic Server 12c. This is your chance to immerse yourself in learning how WebLogic Server 12c supportes the Java EE 6 standards how Maven support is enhanced and made much more feature-rich, extensive integration with NetBeans and Eclipse will be practised using hands-on lab sessions, and there will be opportunity to learn about Coherence as well.

The complete agenda and session abstract is available here.

When ?
Americas, Jan 24, 2012
Europe/Russia: Feb 7th, 2012
Asia Pacific (English): Feb 9, 2012
Asia Pacific (Chinese): Feb 21, 2012

Just register online here!

Also check out the following useful links:
  1. Replay from online launch event + developer deep dive
  2. WebLogic Blog
  3. Online Documentation
  4. WebLogic Server Data Sheet

Also check out the social presence of WebLogic by clicking on the image below:

All the information about WebLogic Server is available from!

Thursday Nov 17, 2011

Devoxx 2011: Java EE 6 Hands-on Lab Delivered

I, along with Alexis's help, delivered a Java EE 6 hands-on lab to a packed room of about 40+ attendees at Devoxx 2011. The lab was derived from the OTN Developer Days 2012 version but added lot more content to showcase several Java EE 6 technologies. The problem statement from the lab document states:

This hands-on lab builds a typical 3-tier Java EE 6 Web application that retrieves customer information from a database and displays it in a Web page. The application also allows new customers to be added to the database as well. The string-based and type-safe queries are used to query and add rows to the database. Each row in the database table is published as a RESTful resource and is then accessed programmatically. Typical design patterns required by a Web application like validation, caching, observer, partial page rendering, and cross-cutting concerns like logging are explained and implemented using different Java EE 6 technologies.

The lab covered Java Persistence API 2, Servlet 3, Enterprise JavaBeans 3.1, JavaServer Faces 2, Java API for RESTful Web Services 1.1, Contexts and Dependency Injection 1.0, and Bean Validation 1.0 over 47 pages of detailed self-paced instructions.

Here is the complete Table of Contents:

The lab can be downloaded from here and requires only NetBeans IDE "All" or "Java EE" version, which includes GlassFish anyway. All the feedback received from the lab has been incorporated in the instructions and bugs filed (Updated 49559, 205232, 205248, 205256).

80% of the attendees could easily complete the lab and some even completed in much less than 3 hours. That indicates that either more content needs to be added to the lab or the intellectual level of the attendees at the conference was pretty high. I think the lab has enough content for 3 hours but we moved at a much more faster pace so I conclude on the latter. Truly a joy to conduct a lab to 40 Devoxxians!

Another related lab that might be handy for folks is "Develop, Deploy, and Monitor your Java EE 6 applications using GlassFish 3.1 Cluster". It explains how:
  • Create a 2-instance GlassFish cluster
  • Front-end with a Web server and a load balancer
  • Demonstrate session replication and fail over
  • Monitor the application using JavaScript
The complete lab instructions and source code are available and you can try them.

I plan to continue evolving the contents for the Java EE 6 hands-on lab to cover more technologies and features and will announce them on this blog. Let me know on what else would you like to see in the future versions.

Saturday Sep 03, 2011

JCertif 2011 - The State of Java under Oracle, GlassFish 3.1, and Stickers

JCertif 2011 was kicked off this morning by Max Bonbhel - the fearless president of JUG-AFRICA, an umbrella JUG for the entire continent of Africa, and the founder of Congo JUG. There were about 200+ attendees in the room. With a single track, the speakers had attention of all the attendees. I gave a keynote on "The State of Java under Oracle" and a technical session on "GlassFish 3.1: Deploying your Java EE 6 Applications".

The conference is well organized and the event staff is very knowledgeable and willing to help. Its amazing to know how Max knows each and every detail and going an extra mile to make the speakers and attendees feel welcome. The keynote was well received and the audience was extremely interactive after the presentation, which is the fun part anyway. And I experienced a similar level of interaction after the GlassFish session as well. I also shared brand new GlassFish stickers with the audience and it turned out to quite a hit (check the pictures below and in the album).

The slides from the keynote are available:

And the slides from the GlassFish session are available below:

Here are some pictures from the trip so far:

And the evolving album at:

Now looking for my last session on OSGi-enabled Java EE Applications using GlassFish tomorrow. You can check out Oracle @ JCertif 2011 for the complete list of sessions delivered by Oracle!


Friday Sep 02, 2011

JCertif 2011 University - Java EE 6 Hands-on Lab

Brazzaville is the largest and capital city of the Republic of the Congo and is the host of JCertif - the biggest Java community event in central Africa. Its a really long flight from San Francisco (about 22 hrs flight time) and takes you in the Southern Hemisphere. But the excitement in developers was every bit worth traveling. Also met this awesome guy in the flight working for World Health Organization who are consolidating their 100 disparate systems using Oracle CRM.

However I got the very first feel of Africa when I was stopped at the Congo-Brazzaville immigration for the yellow fever certificate. In spite of me clarifying multiple times that the visa is already stamped on my passport and I submitted my yellow fever vaccination certificate to the Congo consulate in the US, the immigration officer just kept repeating "phortee dhollar". The immigration office is no place to fight for your principles especially when you don't know the local language. So I cringed, paid $40, got a receipt, got a fake yellow fever certificate, and finally got out. The immigration officer was almost ready to inject the yellow fever vaccination to me which fortunately I avoided. But just as a travel tip, make sure to carry your vaccination card whenever you enter Central Africa in general. It does not matter whether you have the visa pre-stamped or not. Another fellow passenger was charged $10 because his vaccination fever was valid from a later date. Taking a taxi from the airport to the hotel was another challenge because of the local language. But the airport staff was very helpful and I finally reached the hotel safely.

Anyway, the first evening was spent in meet-and-greet the JCertif team. There were JUG leaders from Nigeria, Kinshasa, Togo, and other organizers. The expected attendees on that day were 70 and the actual were about 150 which posed a logistical challenge but they handled it gracefully.

Earlier today, about 50+ attendees got a 4-hr crash course in Building Web Applications using Java EE 6, NetBeans, and GlassFish. The workshop built a complete end-to-end application using Java Persistence API, Enterprise Java Beans, Contexts and Dependency Injection, Servlets, Java Server Faces, and other technologies. NetBeans wizard-drive approach and rapid deployment on GlassFish makes the entire process quite a breeze. Most of the attendees could complete the lab and then started helping other attendees as well.

The slides used in the workshop can be downloaded from here and the source code built during the lab can be downloaded here.

Here are some pictures from the trip so far:

And the evolving album at:

JCertif University is now over and the conference starts tomorrow. You can check out Oracle @ JCertif 2011 for the complete list of sessions delivered by Oracle!

Wednesday Aug 17, 2011

Oracle at JCertif 2011

The continent of Africa has a special place in my heart primarily because of some of the excellent runners it has produced over the years. Living in the United States one can only aspire to be like them :-)

However I'm excited to share that I'll be making my first visit to this continent and speaking at JCertif 2011 - the biggest Java community event in Central Africa.


Here are the different speaking sessions:

Sep 2 Java EE 6 Hands-on Workshop
Sep 3, 10:30am The state of Java with Oracle (a year later)
Sep 3, 3:30pm Deploying your Java EE 6 Applications on GlassFish 3.1
Sep 4, 1:30pm OSGi/Java EE: Architecture and Programming
Sep 4, 3:30pm Java FX 2.0

Here are some more links:

And I'm definitely interested in running together so let me know if you would like to join :-)

I'll be there, will you ?

Friday Aug 12, 2011

Dallas Tech Fest 2011 Trip Report

You're in Texas when 85F at 8:30am is not considered warm or there is a 28-day spell of 100F :-)

Dallas Tech Fest, used to be called as Dallas Code Camp, has its fourth annual conference running in, of course, Dallas. The agenda was packed with 100+ sessions by 70+ speakers over 2 days. This is the first time the event has expanded from the usual one day to two day format. With up to 10 sessions running in parallel, about 300 attendees (my guess) had a lot to choose from.

This was my second year in a row and I gave a 3 hr workshop on Java EE 6 and also talked about how GlassFish 3.1 is the best platform for deploying your Java EE 6 applications.

The slides are available:

There were about 30 attendees in/out of the workshop with a high degree of interaction. The slides provide the code templates in the workshop and the actual detailed steps will also be available as a screencast soon. The complete code built during the workshop can be downloaded here.

The GlassFish 3.1 slides are also available:

Did you know that GlassFish 3.1.1 runs on JDK 7 ? TOTD #169 shows how to use multi-catch, TOTD #168 shows how to use Switch statement in Strings, and TOTD #167 explains how to use Automatic Resource Management to write optimized and cleaner code.

The overall logistics of the event pretty flawless and University of Texas is a beautiful location other than the 100C temperature ;-) I wanted to attend the Community Leadership Townhall but decided to leave early to reach home on time for a Hindu festival over the weekend.

You can follow the twitter stream at #dtf11. One thing that was quite obvious was the intrusion caused by the event photographers. I certainly experienced that as a speaker and I saw several tweets by attendees feeling annoyed as well. The shutter clicks were fairly loud, the flash was right in the eyes (without a bounce), they were going in way too close to the speakers (probably because of lower ISO), and sometimes even obstructing attendees' view too ;-) IMHO, they should take lessons from James Duncan Davidson who do a marvellous job of capturing photographs of different O'Reilly conferences.

Here are some pictures captured from the event:

Many thanks to Tim Rayburn and Erik Weibust - the fearless local community leaders - for providing me with an opportunity to share the technology and my passion with the audience.

A decent 7mile run at the nearby Anderson Donner Park with a single track running trail for a few miles was an overall good beginning to the day anyway:

And finally the complete photo album at:

Wednesday Aug 10, 2011

TOTD #169: Multi-catch - Using Java 7 in Java EE 6/GlassFish

Project Coin introduces a small set of changes to the Java language making your everyday programming easier. The TOTD #167 explained how to use Automatic Resource Management particularly for a Java EE 6 application. The TOTD #168 showed how to use "String switch statement" for a RESTful Web service. This Tip Of The Day (TOTD) will explain a scenario where multi-catch can be used in Java EE 6 applications.

Consider the following piece of code:

protected void doPost(HttpServletRequest request, HttpServletResponse response){
    PrintWriter out = null;
    try {
        out = response.getWriter();
        out.println("<html><head><title>Servlet TestServlet</title></head>");
        out.println("<h1>Sending email from " + request.getContextPath () + "</h1>");
        for (Part p : request.getParts()) {
            // save the parts locally
            System.out.println(p.getName() + " saved");
       Message message = new MimeMessage(session);        message.setFrom(new InternetAddress(from));        InternetAddress[] address = {new InternetAddress(to)};         message.setRecipients(Message.RecipientType.TO, address);         message.setSubject("File upload successful.");         message.setSentDate(new Date());         message.setText("File has been successfully saved.");         Transport.send(message);
        out.println("</body>");         out.println("</html>");     } catch (ServletException ex) {         Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex);     } catch (MessagingException ex) {         Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex);     } catch (IOException ex) {         Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex);     } finally {         out.close();     } }

If you are familiar with Java EE 6 then you'll understand that this fragment is from a Servlet responding to a POST request. This fragment receives a multi-part message such as a file, saves it locally, and then sends a confirmation email. The fields used for sending an email are initialized in the "init" method of the Servlet (not shown here for brevity).

If you notice then there are 3 "catch" blocks and each one of them is executing the same code, printing a log message. Using JDK7 multi-catch block, the different "catch" blocks can be combined together and rewritten as (highlighted in bold):

} catch (ServletException | MessagingException | IOException ex) {
    Logger.getLogger(TestServlet.class.getName()).log(Level.SEVERE, null, ex);
} finally {            

If you have configured NetBeans 7.0.1 for the JDK7 Source/Binary format then it will show you a hint as shown below:

The catch parameter of a multi-catch clause is regarded as implicitly final. An explicit final modifier will be redundant and one more way JDK7 enables more concise syntax.

How are you using JDK7 features in Java EE 6 applications ?


Java EE 6 Workshop and GlassFish 3.1 at Dallas Tech Fest 2011

After a packed Java EE 6 workshop at Dallas Tech Fest 2010, Java EE 6, GlassFish, and NetBeans are back at Dallas Tech Fest again this year. There are over 100+ sessions in 2 days (Aug 12 and 13) and here are the sessions that I'll be delivering:

Some key pointers for the conference ...

Dates: Aug 12 and 13, 2011
Venue: University of Texas, Dallas
Twitter: @DallasTechFest
Hashtag:: #dtf11
Schedule: PDF Online

And then there is Community Leadership Townhall - Dallas Tech Fest Edition as well. This is happening at a different venue though:

Improving Enterprises
16633 Dallas Parkway, Suite 100
Addison, TX 75001

But the evening is promised to be filled with discussions about issues, ideas, and solutions regarding creating, maintaining, and growing user groups and technical communities. I'm looking forward to participating. Make sure to register!

Any runners coming to DTF and up for a Thursday evening or Friday early morning run ?


Sunday Aug 07, 2011

TOTD #168: String switch statement - Using Java 7 in Java EE 6/GlassFish

Project Coin introduces a small set of changes to the Java language making your everyday programming easier. TOTD #167 explained Automatic Resource Management (ARM) and this Tip Of The Day (TOTD) will explain how to use Strings in switch statements.

Prior to JDK7, switch statement worked on byte, short, char, and int primitive data types and enum. It took us about 16 years to realize that java.lang.String is also a constant and add it to the list of data types supported by a switch statement :-)

Consider the following RESTful endpoint that responds with the color of a fruit:

public class FruitResource {

public String getJson(@PathParam("name")String name) {
if (name.equals("apple") || name.equals("cherry") || name.equals("strawberry"))
return "Red";
else if (name.equals("banana") || name.equals("papaya"))
return "Yellow";
else if (name.equals("kiwi") || name.equals("grapes") || name.equals("guava"))
return "Green";
else if (name.equals("clementine") || name.equals("persimmon"))
return "Orange";
return "Unknown";
Using JDK 7's String switch statement this code can be easily re-written as:

public class FruitResource {

public String getJson(@PathParam("name")String name) {
switch (name) {
case "apple":
case "cherry":
case "strawberry":
return "Red";
case "banana":
case "papaya":
return "Yellow";
case "kiwi":
case "grapes":
case "guava":
return "Green";
case "clementine":
case "persimmon":
return "Orange";
return "Unknown";

The number of characters is pretty similar (669 using switch and 674 without) but the code is much more readable, no chained if-else statements, and slightly better performance (not measured). Couple of things to keep in mind:
  • Check for null before the switch
  • Check for different case letters before the switch

NetBeans 7.0.1 provide a hint if you have a chained if-else statement to take advantage of the JDK7 features. Have you downloaded it yet ? Check out screencast #35 highlighting Project Coin features in NetBeans.

NetBeans 7.0.1 provide complete tooling around JDK7 and GlassFish 3.1.1 allow you to leverage JDK7 features in your Java EE 6 applications.

How are you using JDK7 features in your Java EE 6 applications ?


profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.

Java EE 7 Samples

Stay Connected


« August 2016