Microsoft backs Java for cross-platform mobile apps
- 06 February, 2015 02:53
Over the years, Microsoft has not been the biggest advocate for Java, no matter how pervasive it has become. In fact, the company was entangled in a bitter legal battle over the platform with Java founder Sun Microsystems many years ago. But times have changed. Now, Microsoft Open Technologies, a subsidiary of Microsoft focused on "open" technologies and interoperability, is promoting a Java-based approach to building cross-platform mobile apps.
JUniversal is a free tool for development of native, cross-platform apps in Java, as presented in a recent blog post by Microsoft Open Tech. Meanwhile, JUniversal's own site reads, "Don't just write an Android app. Write a cross-platform Java app." JUniversal, the site says, "lets you write code in Java (like you probably already do if you develop for Android) and take that code to places you never thought it could go." Primarily focused on code-sharing across mobile apps, the technology can extend to nonmobile scenarios.
Developers build code in their favorite Java IDE. In their build scripts, they invoke JUniversal for source code translation to C# for Windows Phone. Soon, they'll also be able to convert the Java code to C++/Objective C++ for Apple's iOS platform or for performance-critical code on Android NDK/Windows. Google's j2ojbc converter can be used to convert to Objective C.
Though it still has "rough edges," the tool is available for developers to try out now. "Is JUniversal stable enough today to ship production apps based on it? In many cases yes, assuming you get it working for your needs, but please reach out before shipping so we can talk through any caveats," the site says.
The vision for JUniversal came from Nokia employees experienced in Java and building cross-platform apps, Microsoft Open Tech says. "They built this tool to provide an elegant way to translate source code and make it useful across multiple platforms."
A key design goal for JUniversal is preserving comments and formatting, producing translated source "that looks much like how a human would write it," says Microsoft Open Tech. With this in mind, the debugger, profiler, and exception stack traces all work the same as they do with handwritten source. Thus, translated source code can combine seamlessly with native code: "There's no language impedance mismatch."
For nonshared parts of code, developers must write those in the native platform language, such as C#, Swift, Objective-C, and so on. JUniversal also does not currently provide any support for the UI. The plan is for the UI to be written natively. Also featured in JUniversal is a set of libraries called JSimple, providing cross-platform-friendly versions of APIs needed for most mobile apps. These include OAuth, JUnit, file and network I/O platform wrappers, collections (including HashMap and ArrayList), and logging.