Motivation
After several years
spent in EJB world I wanted to come back to mobile apps development
with some hobby projects. So there was a need to find some free,
popular and comfortable Java mobile framework. The goal was to build
modern multi-platform mobile app. I've decided to do a short research
to find the most popular technology. Then I've realised it's not that
easy to find the most accurate answer in just five seconds.
Article Updated 2016-01-08: added section about Codename One and described license information regarding the Titanium,
Article Updated 2016-04-15: Xamarin killed RoboVM
GWT
The obvious thought
was about GWT (http://www.gwtproject.org/). But pure GWT was not
exactly what I wanted to use, since I have some GWT experience. I
remember about some traps. In the other hand I know that this
technology has been transformed from a Google project to a fully open
sourced project and GWT 3.0 is on the horizon. Now the community
keeps working on making the GWT better and better. At the moment GWT
2.8 supports Java 8, JsInterop, SuperDev mode, and much more…
http://goo.gl/FCDBgT
https://goo.gl/bRjmZY There is
also built-in support for third-party open-source libraries like:
Polymer and Polymer Elements.
GWT-Polymer
I think I have to
look a lot closer at GWT-Polymer, what seems to be quite promising as
you can see in this tutorial.
It's possible to build web apps quite easy using Polymer Web
Components. What more, there is also a possibility to quick-start
development with one of the templates like here:
http://goo.gl/4TH6h7. The Java
wrapper enabling Polymer Elements to be used in GWT project is named
GWT-Polymer-Elements and is
being developed by Vaadin Ltd. You may want to see also this
showcase.
Picture
source:
http://gwtmaterialdesign.github.io/gwt-material-demo/#!templates
When I started my
research I was interested in rapid development. The goal was to less
concentrate on GUI and Widgets and focus more on application business
logic. The templates mentioned above gave me such possibility, but I
decided to continue my research to get full overview and...
mGWT
...the next
technology I had a look was mGWT http://www.m-gwt.com/
which makes easier to create great looking and phonegap ready GWT
based mobile apps. It brings typical mobile widgets and very
performant animations to GWT applications. The technology has been
developed by Daniel Kurka – the person very well known in GWT
world. Daniel seems to be very busy recently, but with help of other
project's contributors he found time to keep it compatible with
recent GWT versions. If you want to have a look how does it look
like, let's see this showcase:
http://mobilegwt.appspot.com/platform/.
I think it's still interesting technology. More info can be found
here: https://github.com/mgwt/mgwt/wiki.
After I looked at the examples, I have to say that I dislike some
conventions in this technology (and in GWT in general). There are
lots of framework's code elements accessed in static
way. But I think it should be possible to inject most of them with
using GIN (Guice for GWT). My goal is to write easy to test
clean-code.
Picture
source: https://github.com/mgwt/mgwt/wiki
Twitter Bootstrap wrapper
There
is also a wrapper for Twitter
Bootstrap which is very popular (demo
site).
You will be able to develop responsive, mobile-first apps in GWT by
using plenty of components quite similar to those
from
mGWT. You can start with this starter project.
If you feel bored
with Java, there are other JVM languages like Kotlin.
This modern language is already quite popular and there is also
wrapper for Bootstrap - the framework named Yested
(demo site).
Picture
source:
https://www.script-tutorials.com/responsive-website-using-bootstrap/
jQuer Mobile wrapper (jqm4gwt)
Quite similar results to those obtained by mGWT and Twitter Bootstrap wrapper, can be achieved also with jqm4gwt as you can see in this showcase. It's well documented and still mainained! I see some commits pushed to the GitHub repository a few days ago!
Picture source: https://internetperformanceexpert.files.wordpress.com
J2Objc
If about the
technologies around GWT or Kotlin JavaScript compiler the code will
be compiled to JavaScript and then with using for instance PhoneGap
can be run on the mobile device. But what about the multi-platform
native app?
Picture
source:
http://www.amongtech.com/best-tools-to-develop-a-mobile-app-for-android-and-ios/
There is the
technology called J2Objc which
provides possibility to translate Java source code to Objective-C for
the iOS. So then I think is should be possible to write the
cross-platform native app quite easy. The project would be split in
tree parts: “android”, “ios” and “core”. So the platform
specific GUI related code would be placed in the proper place and
could be build with available tools like Android UI Designer or
Interface Builder provided by Xcode.
There is already a
technology which joins this everything in similar way named…
RoboVM
One of the main
benefit's of RoboVM is that it
brings iOS to the Java community.
Anything you can do
in Objective-C or Swift you can do in Java using RoboVM.
Build native UI’s
with full hardware access using Java. But also it lets you create
native apps for both iOS & Android by sharing code between
platforms. More info can be found here - Cross-Platform
Basics.
In this article I
decided to focus on the free and open-source technologies. In fact
this is not free, but you may qualify for special pricing.
Open-source developers can receive a free RoboVM license for
non-commercial purposes.
The RoboVM is my
choice. Although it's possible to run RoboVM Studio on Linux or
Windows, but if you want to develop iOS interface related code, you
need to have Mac with Xcode.
Picture
source: https://robovm.com/
JavaFX
It seems be too
late, but better late than never. JavaFXPorts
is the open source project that brings Java and JavaFX to mobile and
embedded hardware, including iPhone, iPad, Android devices, and the
Raspberry Pi. JavaFX can be used with RoboVM (https://goo.gl/7RvC1X).
Picture
source: http://gluonhq.com/open-source/javafxports/
What about game
development? There is the LibGDX
– the Java framework for Cross-platfrom game development. This
framework provides lot of features.
It's well documented.
Works with RoboVM.
It's simple to get
started with this technology using the stub
generator.
Picture Source: https://github.com/libgdx/libgdx/wiki/Project-Setup-Gradle
Titanium4j
There is also another technology which is worth attention. It's free and open source Titanium4j (developed by Ahomé IT) which is built on the top of Titanium Mobile.
Appcelerator licenses Titanium under the Apache 2 license and is free for both personal and commercial use. To experience full platform power you can go for pro options. For Titanium Mobile those prices are only if you use Appcelerator platform products.
As I discussed with Ahomé IT's guy for Titanium4j it's enough to use CLI and SDK. It's possible to use the command line tool and publish apps for free. Then it works this way. I will also write a blog post soon with the result of my own tests.
The code will be easily shared across platforms. They promise also that this technology brings lots of features that make native mobile development a pleasure.
It's worth to mention that it's possible to combine Titanium4j with other technologies, for instance with mGWT. Please see the example here.
I will take a closer look at this technology!
Picture source: http://www.appcelerator.com/
Touch4J (ahome-touch)
The
ahome-touch (also known as
Touch4J) is a Java wrapper for
Sencha Touch. Unfortunately the Touch4J hasn't been well documented so far (absolute lack of documentation). The GitHub repo is continuously updated and this technology is successfully used with company's internal projects. Ahomé IT developer confirmed that Touch4j works pretty well with GWT 2.7. They consider also move to the new JS Interop when adding support for 2.8.
Picture source: http://www.ahome-it.com/project/touch4j/
Vaadin
Vaadin is already very well known
technology. Vaadin Framework is a Java server-side framework for building single page web applications. Even it's free,
to fully use it and boost the productivity, it's worth to consider buying commercial add-ons and components.
Picture source: https://vaadin.com/framework
Codename One
The Codename One founders are engineers connected with Sun Microsystems. This technology allows you to build native apps across multiple mobile operating systems using a single code base in Java.
Supported are: iOS, Android, Blackberry, Windows 7 and other devices.
The SDK and all the tools within it are Open Source and completely free for both commercial and private use.
There are also pro subscription or private cloud option. In the free version of for cloud/push services you are limited to 100 credits per month (for instance iOS build taking up 20 credits). Codename One is an open source project and that includes all the pieces including the native device ports, so it means there is building offline approach too. But then Codename One team doesn't provide help and you have to rely on Community Support. So the suggested approach is to use the build server which generates a native application for you without having to deal with all of the complexities of building a native app for every platform.
If about the way it works... Competitive cross-platform mobile development toolkits typically use HTML5 or heavyweight technology.
Codename One utilizes lightweight technology which translates all the code to native code or the native VM resulting in performance that matches the performance of native code.
When you have a look on this short features demo, it looks really exciting and like a great tool for Rapid Development!
It's possible to build apps with Netbeans, IntelliJ IDEA or Eclipse using the proper plugin.
Then you can simply run the app in the device simulator, debug it, record unit tests, inspect, etc. The work can be supported by the UI Designer Tool. There are also features like certificates wizards. One of the interesting features is that you doesn't need a Mac for iOS development.
I'm really excited about this solution!
Image source: http://www.drdobbs.com/jvm/codename-one-your-mission-is-single-code/240147813
Decision
As already mentioned, I've chosen RoboVM. My decision stems from the need of access to low-level platform functions related to sound (Android's Audiotrack). But in case of the other requirements I would consider the use of GWT-Polymer, Codename One or Titanium4j.