Java Swing UI on iPad, iPhone and Android
Apple is selling iPhones and iPad as fast as they can make it. In Q4 of 2011 iPad outsold PCs for the first time in history. And while PC market is struggling to show any signs of growth, the mobile devices market is growing at 25-35% annually with no signs of a slowdown. Unless you were living under a rock, you know that modern applications have to support iOS devices as well as other mobile platforms such as Android and Windows Phone. Web applications, being the linga franca of the internet, will run on any device with a browser. But what about Java desktop applications written in Swing?
Best option would be to wait for Apple to release Java on iPad, but as Steve Jobs' infamous quote goes "Java's not worth building in. Nobody uses Java anymore. It's this big heavyweight ball and chain."
So you can't count on having a JVM on iOS devices, WebStart is not coming to mobile devices, and if you have Swing desktop application or applet your only option if to rewrite it in Objective C and re-design UI in HTML.
If you have a decent size codebase, rewriting application can be a very big and expensive undertaking.
If you already spent years developing your application, would you want spending them again, getting new bugs and all this just to support new platform?
Obviously that doesn't sound like the best solution, so let's try to find a way to run Java on iPad with minimal effort.
GWT table component demo in Firefox:
Let's try to compare AjaxSwing and GWT:
|Compilable (runtime type checking, refactoring, early error detection)||Yes||Yes|
|Requires JRE on the client||No||No|
|Access to all Java APIs in the client code||No||Yes|
|Ability to run on mobile devices||Yes||Yes|
AjaxSwing uses a 3 steps approach for converting:
- Take working desktop application
- Copy files to the web server
- Open application in a browser
SwingSet2 application in Firefox using AjaxSwing:
Let's take a look at advantages of using AjaxSwing that we found:
- Works in any recent browser including: iPad, iPhone, Android, Chrome OS and normal browsers
- No need to install anything on client device, you just provide them with an URL
- No need in registering in Apple store if you don't want to
- Only UI HTML markup is passed to browser, all your logic and data running on server
- Using AjaxSwing themes you can get native Android and iPhone look and feel
- ... and most importantly, leverage existing UI codebase instead of rewriting from scratch
- Requires internet access on your mobile device
- Requires server with deployed application
- Working a little bit slow in IE7 in our tests
- We didn't found iPhone themes in community edition of AjaxSwing
- Less scalability than GWT or an optimized native app
Below is a screenshot of SwingSet2 running natively on a JVM. Compare it to previous screenshot made from AjaxSwing deployment:
AjaxSwing seems to be a mature product with first version dating back to November 1999. The home page is showing a number of prominent clients including Symantec, Nokia and Bertelsmann. If you are a company or a developer, having Swing application, and willing to release it for iPhone and iPad, you should try AjaxSwing as an alternative to rebuilding your application.
You can open AjaxSwing demo directly from your iPhone, iPad or Android device and check it out yourself.