JavaOne Java Strategy keynotes

Please note: A full-length video of the keynotes is available on the JavaOne 2012 channel of the Oracle Media Network. Shorter, heavily cut “teaser” video clips of all JavaOne and Oracle OpenWorld keynotes can be found on the Video on demand page of the JavaOne website.

The keynote is also covered in detail on the official JavaOne blog.

Today, Sunday the 30th, the Java Strategy Keynotes were the main opening event of the conference. The speakers were these senior Oracle representatives:

  • Hasan Rizvi, Senior VP of Product Development: High-Level Java Strategy
  • Georges Saab, VP Software Development: Java Progress and Status update
  • Nandini Ramani, VP: JavaFX and Embedded Overview
  • Cameron Purdy, VP Development: JEE Status and updates

Oracle will also make all keynotes available as on-demand videos (check the “JavaOne” section on that page).

Make the future Java

The slogan of JavaOne 2012 is “Make the future Java” and Oracle’s overall strategy seems to be a continued effort to move Java forward on all levels:

  • Java the language and platform (JSE, via OpenJDK)
  • Rich clients (JavaFX, HTML5, JEE: Websockets, JSON, improved JAX-RS)
  • Mobile and Embedded (JME, JME-E, JSE-E, JavaCard)
  • App Servers, Middleware (JEE7, via Glassfish community)
  • Developer Tools (mostly via Netbeans)

Status and Announcements

The keynotes consisted mainly of status summaries illustrating progress that has been made over the last year and release or project announcements by Oracle and invited partners.

Java Standard Edition (JSE)

  • New Oracle supported platforms in 2012: OS X, Linux ARM
  • Java 7 replacing Java 6 on cloud servers (80% vs 20%)
  • More than 200 million downloads of current Java 7, update 7
  • OpenJDK: 68 new contributors
  • A lot of activity and momentum in various OpenJDK projects
  • New features are available in early access releases of Java 8

Featured project:

Phil Rogers, AMD, announced a contribution to Project Sumatra that will bring Heterogenous Systems Architecture (HSA) support to the JVM to enable parallel code execution on CPU and GPU.

Rich clients (JavaFX, HTML5)

Oracle continues to advance JavaFX as its strategic technology for modern UIs. In the long run it is meant to replace Swing. At the same time tool support for HTML5 is improved significantly.

  • JavaFX 2.2 for Java 7 is available for Windows, OS X and Linux
  • JavaFX 2.2 is co-bundled with the latest Java 7 JDKs
  • Project OpenJFX started
  • JavaFX to be completely open sourced by end of 2012
  • JavaFX Scene Builder 1.1 is now available for Windows, OS X, Linux
  • Upcoming NetBeans 7.2 will include integrated SceneBuilder</li
  • JavaFX 2.2 comes with support for Swing, SWT and HTML5 integration
  • Project Easel brings improved HTML5, JavaScript and CSS support to Netbeans

Featured Product:

Navis and Canoo use JavaFX for the visualization of container terminals. Canoo’s Project Dolphin provides a JEE server + JavaFX client architecture, now available as Open Source at github.

Mobile and Embedded Java

Oracle sees “The Internet of things” as an important 3rd stage of the internet (after internet of computers and people) and therefore targets all ranges of embedded and M2M (“machine to machine”) devices with Java Technology:

  • JavaCard technology
  • JME Embedded, JME Embedded Client aka OJEC (Linux/ARM, Linux/MIPS)
  • JSE Embedded
  • Java Embedded Suite 7.0 (JSE-E, minimal Glassfish, REST, Java DB)

Roadmap:

  • JME will become a proper subset of JSE
  • JME and JSE releases will occur at the same time

Featured products:

  • The Royal Canadian Mint presented “MintChip“, a digital currency solution that uses USB sticks based on JavaCard technology.
  • Axel Hansmann, Cinterion, announced the world’s smallest M2M module, running JME Embedded, as a breakthrough in the M2M market place.
Java Enterprise Edition (JEE)

JEE 6 is now widely supported and in use (14 implementations have passed the TCK).

JEE 7 builds further on the principles of Developer Productivity (convention over configuration, less boiler-plate code, more modular, e.g. using annotations and resource injection. Another goal is portability across vendors and “across clouds”.

JEE 7 is planned to be released in April 2013, with Glassfish 4.x as the reference implementation. Some stats about current JEE 7 efforts:

  • 33+ specs
  • 14 active JSRs
  • 19 Spec Leads
  • 32 companies contributing
  • 23 projects on java.net

Some JEE 7 highlights:

  • WebSockets API
  • Servlet 3.1 NIO
  • Server Sent Event
  • JSON API
  • JAX-RS 2.0
  • JMS 2.0

Based on general agreement of various JSR stakeholders some technologies have not been standardized, because they are not yet mature enough or don’t have clear enough common denominators:

  • The “Platform as a Service” (PaaS) aspect of JEE
  • NoSQL storage APIs (although experimental support for MongoDB and Oracle NoSQL exists in EclipseLink)

Featured Product:

Nike’s FuelBand gadget (“Life is a Sport: Make It Count”) and service uses JEE on the server side for the tracking of physical activity data to feed into a “motivational web and mobile experience”.

A font chooser combobox for Swing or AWT components

Useful if you want to let the user choose the font to use for certain components of a Swing UI:

package net.doepner.ui.text;

import java.awt.Component;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Arrays;
import java.util.Comparator;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

public class FontChooser extends JComboBox<Font> {

	public FontChooser(final Component... components) {

		final Font[] fonts = GraphicsEnvironment
				.getLocalGraphicsEnvironment()
				.getAllFonts();

		Arrays.sort(fonts, new Comparator<Font>() {
			@Override
			public int compare(Font f1, Font f2) {
				return f1.getName().compareTo(f2.getName());
			}
		});

		for (Font font : fonts) {
			if (font.canDisplayUpTo(font.getName()) == -1) {
				addItem(font);
			}
		}

		addItemListener(new ItemListener() {
			@Override
			public void itemStateChanged(ItemEvent e) {
				final Font font = (Font) e.getItem();
				for (Component comp : components) {
					setFontPreserveSize(comp, font);
				}
			}
		});
		
		setRenderer(new FontCellRenderer());
	}
	
	private static class FontCellRenderer 
			implements ListCellRenderer<Font> {
		
		protected DefaultListCellRenderer renderer = 
				new DefaultListCellRenderer();
		
		public Component getListCellRendererComponent(
				JList<? extends Font> list, Font font, int index, 
				boolean isSelected, boolean cellHasFocus) {
			
			final Component result = renderer.getListCellRendererComponent(
					list, font.getName(), index, isSelected, cellHasFocus);
			
			setFontPreserveSize(result, font);
			return result;
		}
	}

	private static void setFontPreserveSize(final Component comp, Font font) {
		final float size = comp.getFont().getSize();
		comp.setFont(font.deriveFont(size));
	}
}

Java DSL for object-oriented type-safe CSS styling

I am looking for something like this Java-CSS-Library, to implement server-generated CSS stylesheets backed by a type-safe object-oriented model of CSS classes and rule sets.

This is part of my ongoing quest for the perfect “pure Java” web development framework that would allow me to

  • Focus on my strongest area of expertise: Elegant Java code
  • Use refactorings and other advanced Java tooling in Eclipse or IntelliJ Community Edition
  • Ignore the HTML/HTTP vs JVM objects impedance mismatch as much as possible

Sharing IntelliJ project configuration (.idea, *.iml) in version control

Me and my team do exactly what Christof Schablins describes in this blog post and what the Jetbrains folks recommend here: We use IntelliJ IDEA and share *.iml files (modules) and most files in .idea directory (project config) in the Version Control System (in our case CVS), including shared ant configs, shared run configs for Tomcat 6 and JUnit tests, shared project specific code inspection profile, shared data source definitions, etc.

Overall it works great. But we noticed a few things:

  • Needed an IntelliJ Path variable TOMCAT_HOME because devs have Tomcat installed in different places
  • Dialog “Do you want to add workspace.xml to CVS” keeps popping up (despite an entry in .cvsignore file within the .idea directory)
  • If devs have different sets of IntelliJ plugins enabled, each plugin adds its default code inspection rules to the shared profile (even if the project does not use them, e.g. Ruby stuff in a pure Java project). So developers have to be cautious not to check in those changes (or accept the bloat they cause)

So my question is: Have you come across these or similar issues and did you solve them?

Turn org.w3c.dom.NodeList into Iterable

I recently posted some reusable code that facilitates reverse iteration over a list in Java.

Here is another potentially useful Java method related to iteration, from my buddy Jordan Armstrong:

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
  /**
   * @param n An XML node list
   * @return A newly created Iterable for the given node list, allowing 
   *         iteration over the nodes in a for-each loop. The iteration 
   *         behavior is undefined if concurrent modification of the node list
   *         occurs.
   */
  public static Iterable<Node> iterable(final NodeList n) {
    return new Iterable<Node>() {

      @Override
      public Iterator<Node> iterator() {

        return new Iterator<Node>() {

          int index = 0;

          @Override
          public boolean hasNext() {
            return index < n.getLength();
          }

          @Override
          public Node next() {
            if (hasNext()) {
              return n.item(index++);
            } else {
              throw new NoSuchElementException();
            }  
          }

          @Override
          public void remove() {
            throw new UnsupportedOperationException();
          }
        };
      }
    };
  }

Set Firefox “New Tab” page back to about:blank

Recent Firefox versions show a fancy “top sites” overview page every time the user opens a new (empty) tab. This is supposed to allow quick navigation to your most often visited sites.

If you (like me) don’t like the lag (and related security issues) that this adds to opening new tabs then set the new tab behavior back to showing a blank page:

  • Open “about:config” in the address bar
  • Acknowledge the warning to be careful
  • Search for “browser.newtab.url”
  • Right-click, Modify
  • Change the value from “about:newtab” to “about:blank”

Only after writing this blog post, I noticed that there is a Firefox help page that explains the same procedure.

Union and intersection types in Java

Ceylon has union and intersection types at the heart of its type system. Ironically, there is something in Java resembling these powerful concepts, but only in specialized niche contexts and not as “first class citizens” of the type system:

  1. Something like intersection types can be used in generic type boundary declarations (since Java 1.5)
  2. Something like union types can be declared in try-catch blocks that use the multi-catch feature (since Java 1.7)

Interestingly, the Java language engineers used the & and | operators, just like Ceylon. But I have found no evidence so far that they are considering expanding these concepts to the Java type system in general or even let Java developers use them freely in all type declarations …

Update Oct/2012: At JavaOne, I asked Brian Goetz about this. He said that the Java Language team at Oracle has no intention to add additional support – beyond the niches mentioned above – for Union or Intersection types to Java in the foreseeable future.