Hello Ajaxians!
We're inviting all of the Java developers out there to an event organized by our sister site, TheServerSide.com, the Web's largest enterprise Java community. As a member of Ajaxian, you save an extra $100 off the registration fee with the code AJAXIAN. (Register before January 16 to save a total of $400 and get a free book!)
TheServerSide Java Symposium explores current and emerging trends in enterprise Java and how they apply to your daily work. Choose from over 45 technical sessions on new technologies, best practices and practical tips from some of the brightest minds in the industry, including Rod Johnson, Neal Ford, Scott Davis and 35 Java experts.
Tracks include Frameworks, Architecture, SOA, Language, Tools and Techniques.
Project and spec leads dive into:
View TheServerSide Java Symposium agenda to see all of the sessions being presented. Register now with the code AJAXIAN to save an extra $100 and to get a free book while supplies last.
Joe Walker and team have announced the first RC for DWR 3.0. We asked Joe to tell us what is new:
DWR now supports:
- varargs
- method overloading
- typed parameters
- binary file upload/download
- it has a set of new types it can marshall
DWR will let you use JavaScript to implement Java interfaces (e.g. to register a Listener interface to publish changes to waiting browsers using Reverse Ajax), we now have 3 modes to control resource usage and there is a more scalable Reverse Ajax layer.
There are new integrations with Dojo, TIBCO GI and Aptana Jaxer, and a new DOM manipulation library.
We have special asynchronous servlet support for Tomcat and Glassfish, and our Spring and Guice integrations have been beefed up.
We now support JSONP and JSON-RPC, and there's a whole bunch of etc thrown in for good measure too.
There is a more complete list at Joe's blog, or you can just skip straight to the download page.
Jeffrey Sharkey has created OilCan a thin wrapper on top of the WebKit shipping on Android that allows you to install userscripts that allow you to access to Android "Intents".
Intents are very nice abstractions that allow you to access large components and reuse them in different ways. Romain Guy has a nice post on them.
OilCan lets you customize any website by inserting JavaScript to change the website and help it reach into the Android world using intents.
OilCan inserts some powerful buttons into normal websites, and that power comes from Android intents. We didn't write a barcode scanner or the radar app into OilCan, but using intents we can launch those apps with parameters. We can request the Barcode Scanner app to scan something and return the code to us, or launch the Radar app with a specific lat/lon.
Userscripts can do other cool stuff, like hide the navigation columns in Wikipedia to make it easier to view on small screens. This is a proof-of-concept for now, and will probably turn into a binary plugin for the default Browser in the future.
A nice piece from an example shows the intent call out:
Very cool!

The UML diagram above is from Matt Prokes as he creates Java-like interfaces for JavaScript.
He has a full example:
An example of an object which requires an implementation of the interface.
JAVASCRIPT:
//This code is valid, and the execution will be successful. function executeInterface1(executeThis){ var castedIface = executeThis.cast('TestInterface'); castedIface.testMethod1(1,2,3); } //This code is valid, but the execution will not be successful. function executeInterface2(executeThis){ var castedIface = executeThis.cast('TestInterface'); castedIface.testMethod2(4,5,6); }Alright, lets instanciate, the objects and set them to variables. Feel free to type in the variables and take a look, on the firebug window!
JAVASCRIPT:
InitedTestObject = new TestObject(); //variable not used in this example, but I thought I would still make it available! CastedTestInterface = InitedTestObject.cast('TestInterface');Ok, so lets try it out! We wrap it all up in some simple div tags with onclick events.
HTML:
onclick="executeInterface1(InitedTestObject)" onclick="executeInterface2(InitedTestObject)"
Rodrigo Reyes has announced a new project called AbstractCanvas, a GWT project that sits on top of HTML Canvas and Java2D.
The same code can thus run in the browser, or on the server.
You can then write code such as:
It really is plugin week isn't it. We had Flash and Silverlight, so it was time for Java to pop its head up from the shadows, and that is what happened with the production release of Java 6 Update 10. It has to be one of the worst version names, but a solid plugin release it is! We originally sat down with Ken Russell to talk about this version on October 18th, 2007.
Cote has some nice coverage via his interview with Danny Coward:
When I was in his neck of the woods last, I got the chance to talk with Sun’s Danny Coward, the Chief Architect of Sun’s Client Software (that is, Java SE, Java ME, JavaFX and JavaCard), about Java 6 Update 10. That seems like kind of a narrow topic to speak to, but as Danny and I discuss, it’s a big release for Sun’s RIA and client-side (re-)push.
Along those lines, we spend a lot of time detailing the re-written plugin that’s used for Java applets and JavaFX, the improved installer and update experience, and other client side features like one of the new GUI look-n-feels, Nimbus.
I have to admit to not "getting" JavaFX, but the Java plugin features are great to see, and it is nice to see the final release.

I have seen the GWT team working very hard indeed on GWT 1.5, and they must be very happy to see the final release shipped and complete:
GWT 1.5 delivers what we think are an impressive number of improvements, about four hundred issues if you're counting. We're also happy that one of those is issue 168, our most-requested feature, Support for Java 5.
The high level new feature sets are:
You can see a lot of this at work in the showcase area. There you will see all of the widgets and examples that come out of the box, and the community has developed even more for you. In particular, Ray Cromwell has some great real world examples that he shares in his book and talk.
Download GWT and take a look.

Dave Kuhn has put together a comprehensive guide to piecing together GWT and Spring, a nice recipe for the Java heads among you.
Dave starts out by detailing why you would want to do this, and how it changes the architecture of your application.
He then gets to a tutorial that has you creating the project correctly, and configuring an actual service. Once you are done with the code, you need to setup hosted mode to point to a nice external tom cat via:
-out www GwtWisdom/GwtWisdom.html -noserver -port 8080
Ignacio Coloma has announced Loom 1.0 RC 1. Loom is an annotation-based java web framework that includes a ton of new features in this release. After some selective process, these are the bits that could be of most interest for Ajax developers:
Just give it a try at the demo. Try introducing invalid input, and check the sources by clicking the "View source" link at the top right of the page. Everything in the demo should work with javascript disabled, including multiple file upload.
The framework also includes a libraries repository which pulls debug/optimized javascript from the google CDN:
This snippet of code would translate into this, if development is disabled:
Or this if not:
More details about the framework are at the reference guide. Ignacio would be grateful for any feedback!
And now for something a little bit different on a Friday. Greg Brown from VMWare pointed us to the fruition of nearly a year's worth of R&D: Pivot, a new GUI toolkit for Java.

While traditionally Java Applets and the Web have mixed together about as well as concrete and peanut butter, the upcoming revised Java plug-in might give a window for Java-based GUI toolkits to be of interest to Web folks.
While Pivot's source code is still forthcoming, a quick glance at its classes shows an architecture with a strong resemblance to Java's built-in Swing GUI toolkit, but with many of Swing's rough edges smoothed out. As a long-time Swing developer, I'd characterize it as attempt to create Swing++.
Similarities to Swing include a light-weight rendering model (i.e., it doesn't wrap native components), a nearly identical component contract, a very similar system of UI delegates, and a very similar event model. Differences include a cleaner API (by virtue of nixing direct interoperability with Java's ancient AWT toolkit), different approach to layout, fresh implementations of common GUI components, and a new collections framework (inspired by Java's collections framework but... different).
Thinlet is another, older alternate GUI toolkit for Java that draws its own components and targets Applet developers (though a new version is under development).
Joshua Marinacci has detailed how Java SE 6 update 10 supports the same crossdomain.xml that Flash supports, and how you can marry it with JNLP to allow you to do Applet mashups without permission dialogs.
The applet security model, known as the sandbox, only lets applets connect to the webserver they were loaded from. They cannot connect to anywhere else unless they are signed. Signing is great when you need access to more than what is allowed inside the sandbox, but it has two problems: the user will receive an ugly warning dialog about the applet, and the applet will have full access to the user's computer. Full access is overkill when all you want to do is talk to a webservice on another server. Surely there is some middle ground between the sandbox and full access? Well now there is.
The key is supplying a backwards compatible way of tying to the new JNLP version:
Now the JNLP file points to the the unsigned jar:
Note: you should be aware of security issues with open cross domain files.
Scott Schiller has updated one of our favourite libraries, SoundManager. Being able to simply play some audio from your Ajax applications can be great, as long as you don't use it gratuitously.... although we tend to do that a little in some of our demos :) We used SoundManager in our Wii Darts application.
The new version has performance improvements so the sound happens a lot quicker, a few bugs are killed, but most of all you will see some really great demos to cover use cases from users such as "I just want to be able to click and play a MP3 link in-page."
Some of the cool new demos:
Oh, and you gotta love the Web 2.0 and Web 3.0 explanations of SoundManager ;)
Spring Web Flow 2.0 has been released which includes a new Spring JavaScript module.
Here is an example of an onclick wrapper calling an Ajax event:
I got to sit down with Keith Donald and Jeremy Grelle from SpringSource and talk to them about the going-ons on the Web tier. There are a couple of moving parts, from the core Web framework (Spring MVC), to the Spring Webflow controller engine, to the new Spring JS module.
Spring JS abstracts on top of other JavaScript libraries (this release supports Dojo, but more can come), and aims to make certain tasks very easy to do. Jeremy talks about some of the use cases, such as form validation. The library could be used stand alone, but of course there is nice integration with the server side Spring frameworks too. This allows you to annotate in Java, and get nice Ajax behaviour on the client.
Ben and I gave a presentation at JavaOne on what's new with Ajax. Since this was JavaOne, we skewed a little more than we normally would to Java topics, and one of them was using the new Java Plugin, that has great new features such as being able to take a running applet out of the web page, and having it continue to live after shutting down the browser. Java is running out of process here, which also helps the "Java crashing the entire browser" problem.
Anyway, back to our demo. For some context, last year at JavaOne had us performing Guitar Hero on stage, so we knew that we had to use a gaming console in some way. This year it had to be the Wii, but instead of using the console, we decided to just use the controllers.
Wouldn't it be cool to control a Web page using the controllers? We thought so, and we set to it. You can talk to the Wiimotes via Bluetooth, so we needed a stack that would allow us to do just that. Java has a bluetooth stack. We could get an applet to talk to the Java stack. Hmm.
It actually took quite some time to test out the various stacks out there. In the end we went with a native system called Wiiuse that a lot of Wii hackers use. There is a wrapper library called Wiiusej that gave us exactly what we needed.
A quick test later and we had an application that was talking between the remote and the program. It turns out that the main controller sees a series of IR lights that are in the Wii sensor bar, and this allows you to simulate the system with any decent IR source. In the presentation room the big lights that shine on stage were strong enough to act as a sensor bar so we won't even have to use it. We can just point out to the crowd.
Anyway, back to the application. We then wrote a Java class that acts as a state machine for what the remote is doing. It understands the movements, which buttons are pushed, how fast you are moving the device. With this data we could build a simple darts game. With the state machine Java code, and an Applet wrapper that exposed the information, we were ready to get to the Ajax side of the house.
We painted a darts board onto the screen and then had JavaScript start polling the Applet for information via JSObject (As simple as: document.nameofapplet.pollmethod()). This turned out to be more stable than talking the other way, even though it meant we were polling instead of being entirely event driven. When the JavaScript code polled the applet it would pass back a data structure with the data for the coordinates of the remote, and whether the dart had been fired (button A to fire, button B to reload). We would move the dart image on the screen as you move the remote, and when fired we kicked off an animation to fire the dart at the board.
At first, it was all too simple. You setup the shot and it would get the right area every time. Not a fun game. We then decided to add some simple physics to the Ajax game. We took into account the velocity of the throw (if weak it would fall down) and how straight your shot was. If you wiggle around, the dart will not be accurate.
Anyway, this was a lot of fun, and shows that as much as we mock Java applets, if we forget about using them as fancy blink tags, and instead think of them as more extension points, maybe there is life for them.
The video below shows you a demo of the application, the source code with an explanation, and more details.
As John Resig reports, the Japanese Shibuja.JS user group managed to port (at least in parts) the Java Virtual Machine over to JavaScript. The project is called Orto and there is a Japanese PDF explaining the details (I guess) available on John's site.
Using this you can convert Java code into bytecode and embed it in the document.
One of the examples shown is a pretty cool Tetris game:
As Orto simulates the multithreaded nature of Java with yields and timeouts this is of course hard-core simulation (read: hack), but the benefit are that you could Java Games on non-JS devices, like the iPhone.
Orto also seems to try to simulate the Java UI conventions, thus making it easy to convert existing applications (to a certain degree as there is no equivalent in HTML for the richness of Java UIs unless you build them yourself as libraries ike Dojo or Quoxdoo did).
More details are available on John Resig's Blog
Ethan Nicholas of Sun has posted an article on Java 6 update 10 which just came out in beta to play.
For Java folk there are some huge wins, and for the first time in ages the Java applet has huge changes. If Java Applets can get past the sniggering baggage, there is actually interesting things to see there.
What was the pain again?
Once a Java program is up and running, it's generally smooth sailing.
Modern Java Runtime Environments (JREs) are stable, reliable, and fast.Unfortunately, getting to the "up and running" part has historically been
more difficult than it should be. Challenges have included:
- Difficult to detect JREs, especially from a web browser
- Difficult to automatically install new JREs
- Large download size
- Poor cold start performance
- Little overlap between applets and Web Start programs
Java 6u10 was created as a response to these challenges. By carefully
avoiding public API changes, we can get the fixes into your hands sooner --
no need to wait for Java 7!
And the solutions?
Java Kernel
Java Kernel is a new distribution aimed at getting Java software up and running faster. Instead of a full JRE, users download a small installer (the "kernel") which includes the most commonly needed JRE components. Additional components are downloaded as needed, and the JRE will download remaining components in the background and then reassemble itself.
In the current build, the typical download size for Swing programs and Java applets is on the order of 4-5MB, compared to 14.4MB for the full JRE.
Next-Generation Java Plug-In
Java 6u10 includes a brand-new implementation of the Java Plug-in, which is
used by default as long as you are using Firefox 3 or Internet Explorer. The
next-generation plug-in runs applets outside of the browser in one or more
separate processes. Applets still appear inside of the web browser window as
they always have, but this means that it is now possible to use different JRE
versions, command-line arguments, and configurations to run different applets.
The isolation provided by running the web browser and the JRE -- two very large,
very complex pieces of software -- in separate process spaces improves the
reliability of both, and gives applets the same flexibility and control over JRE
configurations that other Java software has always enjoyed.Since applets now feature the same powerful JRE selection and configuration
that Java Web Start programs do, it was only natural to use the same mechanism
for both. The Java Plug-In now supports using Java
Network Launching Protocol (JNLP) files to specify applet configuration and
startup options. With very little additional work, you can now deploy the same
program as both an applet and a Web Start program, and still take advantage of
JNLP services such asPersistanceServiceand
FileSaveService.New Plug-In Advantages:
- Improved reliability
- Improved JavaScript communication
- Per-applet control of JRE command-line arguments
- Per-applet control of JRE memory settings, larger maximum heaps
- JNLP support
- Per-applet JRE version selection
- Improved Vista support
Much more information about the new plug-in can be found in the release notes.
Java Deployment Toolkit
The Java Deployment Toolkit makes deploying Java applets or Java Web Start
programs a snap. The Deployment
Toolkit JavaScript file provides:
The following HTML code is all it takes to ensure that Java 1.6 is installed and
then a Java applet is launched:
Also note, that with this version you can take a running Applet in the browser, pull it OUT of the page, close the browser, and see the applet still running (since it runs in a different process). This is very cool indeed.
Add to all of this the easy bridge between Java and JavaScript, and there are interesting opportunities.
Version 2.0 of GChart has been released:
The main idea behind GChart is simple: You can make very nice charts efficiently out of a reasonably small number of 1-cell Grids (for the aligned labels) and (empty) Images (for everything else), styled and positioned appropriately on an AbsolutePanel. Not surprisingly, bar charts don't suffer at all under the limitations imposed by this strategy--but (as long as you don't mind using dotted connecting lines or banded-filled pie slices) line and pie charts also do remarkably well.
With version 2.0 the library adds support for pie, line, and area charts, baseline-based bar charts, and more.
John Gunther wrote up some of the technical details:
Squaring the Pie Slice
Some of you may recall the original GChart 1.1 post/discussion:
Reading this, you may wonder how I ended up implementing pie slices
and arbitrary angled connecting lines. Did I use the "transparent
border triangle trick" and/or clever algorithms from walterzorn.com?Though I tried to use these, I reverted to something a lot simpler:
dotted connecting lines and banded-filled pie slices. Two new Symbol
class properties, fillSpacing and fillThickness, let you control the
spacing of the dots/bands and their size/thickness.Though this approach means you may sometimes have to choose between
visual chart quality and speed, these new properties make it easy for
you to control this tradeoff. Besides, I like to think that dotted
connecting lines and banded fill pie slices really don't look all that
much worse than the solid fill variety. But then again, I could never
understand why no one ever used square pie charts...In any case, the whole point of GChart is to layer the chart on top of
standard GWT Widgets, so, since those Widgets can only really draw
rectangles efficiently, I decided to make a virtue of necessity and
whole-heartedly embrace this dotted/banded look.CSS Convenience Methods: A cure for "CSS anxiety disorder"?
For many months I suffered from "CSS anxiety disorder": a condition
arising from one's desire to use CSS to specify an attribute (and thus
conform to a GWT best practice) while simultaneously wanting the same
property in the Java API (so that it would not be unnaturally
segregated from closely related features).To address this (possibly imaginary) problem, the GChart 2.0 Java API
includes "CSS convenience methods" that can (optionally) override
traditionally CSS-based attribute specifications for certain selected
CSS attributes.To some, this may seem like a fine point, since you could easily do
the same thing via a GWT DOM class method call, but to me, once you
invoke a DOM method you are thinking of the GChart as an HTML element,
and for some usage scenarios, that just isn't logical.For example, for some applications, the background color of a GChart
is mainly about how the color-scheme of the chart blends in with the
surrounding page, and for these applications a CSS-based specification
makes good sense. Yet, for other applications, it is mainly all about
how well background color matches with, say, with the pie slice
shading pattern. That is, in some cases, background color is better
viewed as a feature of the GChart considered as a Java object
independent of its connection to any web page. So why can't you just
call GChart.setBackgroundColor in such cases? With GChart, you can.To assure that the two specification methods can exist harmoniously
together, GChart recognizes a special property value, GChart.USE_CSS,
which instructs GChart to stand aside and allow the traditional CSS
cascade to define the attribute. For all such "dual access" GChart
Java properties (which are simultaneously also CSS attributes),
USE_CSS is the default property value. This assures that you can use
CSS just as you would with a standard GWT Widget whenever it makes
more sense to control that attribute from the "GChart as HTML element"
perspective.Thanks to these CSS convenience methods, I have attained inner peace
through Java/CSS redundancy. I recommend the same treatment for anyone
else suffering from "CSS anxiety disorder". See the GChart.USE_CSS
javadoc comment for more information.
I am sure that John will be porting this to the GWT for JavaScript 2 at some point soon!