So what's the difference? Well, the OpenJDK is a 100% open-source implementation of the Java language specification. The Oracle Sun JDK is largely open-source but still contains some precompiled binaries that Sun didn't have copyright to release under an open-source license.
You can read more here:
I've always tended to replace the OpenJDK with Sun Java, but since installing Ubuntu 10.04 Lucid Lynx, I've been seeing how I get on with the OpenJDK. To date, developing straightforward Java, JSP and servlets with Spring, Struts2, Hibernate and Maven deployed on Tomcat, has worked perfectly well. I've also been using the IcedTea plugin in Firefox with no issues.
But yesterday, I hit my first snag. If you read my previous post you'll know that I've been looking into the new annotations in the Servlet 3.0 specification: @WebServlet, @WebFilter and @WebListener. To get examples to run I had to install Glassfish v3. All was well until I tried to run the Admin Console and I got this error:
java.lang.UnsupportedOperationException: Cannot create XMLStreamReader or XMLEventReader from a javax.xml.transform.stream.StreamSource at com.sun.xml.internal.stream.XMLInputFactoryImpl.jaxpSourcetoXMLInputSource(XMLInputFactoryImpl.java:283) at com.sun.xml.internal.stream.XMLInputFactoryImpl.createXMLStreamReader(XMLInputFactoryImpl.java:143) at org.jvnet.hk2.config.ConfigParser.parse(ConfigParser.java:109) at org.jvnet.hk2.config.ConfigParser.parse(ConfigParser.java:104) at org.jvnet.hk2.config.ConfigParser.parse(ConfigParser.java:100) at org.glassfish.admingui.plugin.ConsolePluginService.init(ConsolePluginService.java:121) at org.glassfish.admingui.plugin.ConsolePluginService.getIntegrationPoints(ConsolePluginService.java:423) at org.glassfish.admingui.common.handlers.PluginHandlers.getIntegrationPoints(PluginHandlers.java:160) at org.glassfish.admingui.handlers.ThemeHandlers.getThemeFromIntegrationPoints(ThemeHandlers.java:98) ... 47 more
That didn't worry me too much at the time, but I was also getting some odd behaviour with Java Server Faces (JSF) applications that I hadn't seen on Tomcat. Most of the time I'm able to switch freely between one and the other with web applications.
So, based on a forum post about the problems with the Glassfish admin console, I installed all the Sun Java 6 components. My problems with the admin console disappeared and my JSF application started behaving normally again. So, on that basis, there seem to be glitches with JSF using the current version of the OpenJDK. The Glassfish admin console is based on JSF.
If you need to replace your OpenJDK installation on Ubuntu 10.04, these are the steps:
- Enable the partner repositories: System -> Administration -> Software Sources and check the box for
http://archive.canonical.com/ubuntu lucid partnerin the Other Sources tab. You might also want the sources checked too.
- Install the Sun Java6 packages: sun-java6-jdk, sun-java6-jre, sun-java6-source, sun-java6-fonts, sun-java6-bin and possibly sun-java6-plugin.
You'll then need to switch your default Java to the Oracle Sun version:
$ sudo update-java-alternatives -v -s java-6-sun
Do also check that you haven't hard-coded OpenJDK into any JAVA_HOME variables or application settings.