Differences between Java 5 and 6

Abstract

This article contains information about the differences between the Java 5 and Java 6 frameworks. More specifically, it highlights the new features added with the latest release of Java 6. The article covers security, gui, speed, and problems found with the current release. It discusses opinion on the subject as well as attempting to provide fact about the latest Java technology. As our projects gear towards Windows applications, so does this article.

With the new Java 6 emerging, developers all over the world cringe with the questions of compatibility and upgrade. Others are optimistic about chance to tinker with new API’s and tool sets. Although there are a decent number of changes in this update, this article is aimed to expose only the ones we found interesting or important. If we miss some, there is a full list of changes linked at the end of the document. Java 6 appears to be a bunch of small updates packaged as a new release. This is a good thing for those worried about the scope of an upgrade. For those interested in tinkering with new features, the scripting engines and graphical add-ons should suffice. Although there aren’t near as many updates as compared to the Java 4 to 5 upgrade, there are definitely some interesting new additions to the new framework.

First, lets talk optimization. With an expansion of any API or system, slowing down is always a primary concern. However, a large portion of the new Java enhancements are actually speed related. How Java handles desktop applications is now more optimized with faster loading times and double buffering. The adaptive optimization system does even more things to optimize your code upon compilation and runtime. This also applies to split byte code verification which is now done partially at compile-time and partially at runtime. As a note, byte code verification was originally done right when it was about to be used, which slows things down. With all these speed increased, did they mention security features?

This security section starts with an interesting little tidbit about Web Start Applications. Sun appears to be heavily pushing Java 6 with what they call “Security Versioning.” It states that Java Web Start applications not identifying themselves with the latest version of Java will require users to explicitly give permission before executing a particular Java Web Start program. This seems mildly annoying but apt in moving development to newer versions. The site says that signed Java Web Start applications are not affected by the change. Another main security feature added is GSS/Kerberos integration and a certificate request framework apparently working under a large number of protocols. Java added support for a numerous amount of new encryption types. Some little features include SSLParameters class that encapsulates the configuration of SSL connections and new parameters and options for some of the security related classes. The changes even filter down to the socket level. Socket read timeouts are now fully supported where as before, there were inconsistencies. So if you are treading into socketland, you will be happy to know that the libraries are still being supported very well. Networking updates don’t end at the low level however.

Web Services have a wonderful set of updates as well. Cryptography directly on XML is an awaited feature on the enterprise side of development that made it into this release. Support for .NET web services is another interesting feature added to the new implementation allowing ease of interoperability when designing large systems. This feature is documented, although we have not tested it ourselves. The XML libraries use STAX for message processing, and have 2 new tools to aid in development and deployment. They also included a few new classes to make connections and publishing more simple then ever before.

Developers Developers? Yes indeed. From the text above, you can see that Java 6 caters to the developer (as they should since they are writing a development language). And it doesn’t stop there. A developer can now compile code directly from other code within a Java application. What about if the code breaks? All the debugging information including warnings, errors, etc… get sent back to the application so the application can handle things properly. Code generation now seems more powerful then ever. There are also a few more neat little tricks like developers attaching to an existing JVM for more in-depth debugging. Don’t laugh .NET developers, we know you can do that already.

Away from the enterprise server side of things, the User Interface updates are definitely of note. For a Windows developer, these updates have not come fast enough. True double buffering is one notable feature which buffers every window instead of every application. Another nice feature is baseline/gap API’s and text-component printing. They even are nice enough to throw in a custom splash screen that can be used with a swing application for those lengthy load times. Sun seems to finally understand that desktop GUI’s look different depending on the operating system. They have designed the latest version of swing to look different based on the graphical engine running the swing code. Before, this required special code during the Jframe instantiation. For native look and feel, the features include: GTK Native Look and Feel, Avalon Look and Feel, as well as a number of Windows based fixes. These updates are rumored to speed up the graphical side of things quite a bit as previously stated. To add a few more flavors of icing on the cake Java applications have the ability to access desktop applications, they have live updating on window resizing (finally), and some miscellaneous hardware acceleration tweaks are involved. All in all, I would say Java now has a pretty powerful forms application development library. What more could you ask for?

As for miscellaneous features, Java has implemented a nice way to integrate scripting languages in with Java source code. The actual Sun site directly comments on merging JavaScript, Ruby, and Python into custom scripting engines which allow different team members with different backgrounds to integrate code. This framework allows scripting languages to access internal parts of your application with a small code base as the scripting engine. We didn’t spend an extensive amount of time delving into this feature although it is something worth exploring in the future.

With all of these cool new API upgrades, there are some things that confuse us. For example, some of the speed specification documentation is missing from the Sun website. The whitepaper for Java 6 performance redirects to a page simply saying “Coming Soon.” Also, they have appeared to add some features that the community was directly against even though this release was set on community action and involvement. A small scale HTTP server was added to Java 6 which is based on a bug report sent by someone in the community. Every person commenting on the particular bug deemed it unnecessary. As well, a few data types were added to the framework that appeared to be fairly meaningless. The double sided queue was one of those data types. One man’s bloat is another man’s godsend though; I hope people find use in the new types. The most immense bother is the one to one relationship still required by the JVM to launch desktop applications. We are hoping this problem will be dealt with in the near future. The need for a separate JVM for interpreted language was fixed with .NET, and users don’t enjoy the lengthy load times associated with launching two applications for every one application. We won’t mention the memory waste.

Despite the issues, every developer knows that ironing out problems takes a lengthy amount of time. This especially applies to replacing production code which many developers currently rely on. With that said, don’t expect things to be perfect any time soon. The emergence of Java 6 brought some new possibilities in development to the table which everyone loves, although we didn’t see many things catering to our love of coding to robots. There are only a few complaints about the new framework, and none of them seem to hinder the framework enough to justify not upgrading (this especially applies to those interested in Web services and those affected by “Security Versioning”. These new features are essential as this language makes an effort to stay on top.

References

Java SE 6 Release Notes http://java.sun.com/javase/6/webnotes/features.html

Bruno, Eric (2006, February 27) Java SE First Impressions: A Desktop Winner http://www.devx.com/Java/Article/30722

Java 6 Security Enhancements http://java.sun.com/javase/6/docs/technotes/guides/security/enhancements.html

Mullan, Sean (2006, February 15) Mustang Beta is out! Here’s what’s new in security. http://weblogs.java.net/blog/mullan/archive/2006/02/mustang_beta_is_1.html

vivekp (2006, December 12) Webservices in JDK 6 http://weblogs.java.net/blog/vivekp/archive/2006/12/webservices_in.html