Java EE 6: What’s new?

April 13, 2010

Here’s a concise white paper on what’s new with the latest release of Java Enterprise Edition. I recommend reading it.

And here’s a jist of things:

  • Web Profiles – For the light weight web apps where you don’t need a full blown container.
  • Servlet 3.0 – Annotation based, with support for web fragments and asynchronous processing (AJAX just got better).
  • JAX -RS – Restful web services are here.

(read more)

JavaFX: Coming of age

March 31, 2010

When it comes to web pages, I like them plain and simple. Earlier associations of flash and other embedded content with irritating ads and browser crashes makes me cringe when I hear “rich media”. Ajax was refreshing with its unleashing of the hidden powers of CSS and javascript.

But you got to face it. You cannot ignore RIA anymore. If you are going the RIA route, what options do you have?
Flex has been the industry favourite. But again, here’s reasons why (from Adam Bein’s blog) JavaFX is a good option too.

Take a deep dive!

Java Tech Days 2010

March 25, 2010

This being the first tech days post Sun’s acquisition by Oracle,the event started with a keynote from Oracle underlining their commitment to the development of java technologies. Lets jump into the highlights of the last 2 days!

  1. J6EE – This has been the biggest news on the horizon. While J5EE was about cutting the flab in JEE with JPA replacing container managed entity beans, J6EE made the stack much more easier to develop on. The following are the technologies that makes up the Enterprise Edition:
    1. Web Profiles – For the light weight web apps where you don’t need a full blown container.
    2. Servlet 3.0 – Annotation based, with support for web fragments and asynchronous processing (AJAX just got better).
    3. JAX -RS – Restful web services are here.
    4. EJB 3.1 – The business interface are optional now. Also, check out the EJB Lite.
    5. JPA 2.0 – Enhanced JPQL (java persistence query language), metamodel based query support.
    6. Context and Dependency Injection – Standardizes dependency inject in EE applications with seamless lifecycle management of the web beans.
    7. JSF 2.0 – Brings annotation support and templating of facelets.
    8. Bean Validation framework – No more writing validation code in the model. Annotate and forget it.
    9. Connector Architecture 1.6 – Standardizes bidirectional connectivity between the application and Enterprise Information System (EIS).
    10. Packaging Enhancements- Forget the ear files. EJB goes into a single war along with your web apps.
    11. and a lot more!
  2. JDK7 – Modularity and Closures are the buzz words for the new release expected any day. With a lot of new scripting languages out there running on the JVM, Closures does some catching up. Also with the multi language support, you can now pick your favourite from over 200 languages and start coding for the jvm!
  3. Bundles – Bundles is the way to go and that cannot be better emphasized with JDK7 introducing modules as a part of the language. The focus on OSGi and its support in GlassFish V3 could be java’s way of admitting its superiority when it comes to modularity. Go OSGi!
  4. Support for jvm based scripting languages – Groovy, ruby, jython, scala, closures, lisp, jcl .. The list is endless. There are more than 200 languages that are now supported by the jvm.

You can find more about the Tech Days 2010, Hyderabad edition on Arun Gupta’s blog.

compound-assignment operator and type casting

September 13, 2008

We’ve been learning since we first printed “hello world” that

i += 1

expands to

i = i + 1

Well, here’s a little problem to shake the faith.

byte i = 1;

i  = i + 1;


Being java programmers worth our salt, it wouldnt take much to identify the compilation error.

Error: Possible loss of precision

So how do we explain that the next code snippet prints the value 2?

byte i =1;

i += 1;


Here’s the secret: i += 1 is not same as i = i + 1

When you do an assignment (the first code snippet), java enforces type checking because the LHS and RHS may very well be independent of each other.

But the compound-operator is more like an incremental operator. The += modifies the value of the variable involved, rather than assigning a new value to the variable. When you modify a byte, you expect a byte as the result. To make life easier, java does an implicit type conversion for compound-operators because they are modifiers.

Have fun!