Mozilla's upstart Firefox OS mobile operating system badly needs app support. And it may have found its answer in a 20-year-old programming language.

Mozilla

The lack of apps are a common problem for operating systems challenging the two dominant mobile platforms, Google's Android and Apple's iOS. Without crucial software like WhatsApp for text messaging, customers steer clear and head for better supported operating systems from the big two.

But as CNET revealed in May, Mozilla is considering technology to run some Android apps directly on its own OS as a way to bridge the app gap. The nonprofit organization didn't detail its plans, but a project called j2me.js that Mozilla Chief Technology Officer Andreas Gal quietly launched last year could be key.

The j2me.js approach relies on the JavaScript programming language Mozilla founder and former Chief Executive Brendan Eich invented in 1995 for the Firefox progenitor Netscape Navigator. Android apps are written in a different programming language, Java, but j2me.js can translate Java programs so they run on a JavaScript foundation instead.

If successful, the j2me.js approach could help Firefox OS gain a foothold so Mozilla can counter the mobile power Apple and Google hold over most people with a smartphone by running at least the key apps that are in demand. If nothing else, it gives Firefox OS a flicker of life as a fledgling operating system trying to gain the attention of consumers, handset vendors and wireless carriers.

But there are complications. Using software to bridge between operating systems is complex and technically difficult with a poor track record. And even if it works, it's big step away from encouraging developers to write apps directly for Firefox OS.

Technical workarounds also won't help Mozilla solve the chicken-and-egg problem that all iOS and Android challengers face, said Jackdaw Research analyst Jan Dawson. With few users, developers don't write apps, and with few apps, users stay away. On top of that, Mozilla's agenda hasn't been focused on features that consumers are looking for, like camera quality.

"Firefox OS has always felt like it was trying to solve a philosophical problem -- closed ecosystems -- rather than a customer problem," Dawson said. "The vast majority of customers are happy with one of the major operating systems already in the market."

Open philosophy

That philosophy is core to the technological choices Mozilla made since Gal began the Firefox OS project in 2011. And though it may not be enough to sell a phone, it is important.

Mozilla's objective with Firefox OS -- and all its other work -- is to give people more control over their online lives through the use of open software. To that end, Firefox OS is a browser-based operating system, meaning that its apps are written with the same technologies used to build websites -- HTML for content, CSS for formatting and JavaScript for programs. In principle, a Web app can run on any browser, a strong contrast to iOS and Android apps that only run on Apple and Google operating systems.

Screenshot by Stephen Shankland/CNET

The open Web approach breaks the operating system lock: because every operating system needs a browser, a Web app will in principle run on it. It also means users don't have to go through Apple's App Store and iTunes service, or through the Google Play alternatives, to buy their software and download their movies. With an open Web approach, you don't have to purchase Angry Birds all over again if you switch from iOS to Android or vice-versa. Web-based services also make it easier to move without losing data like messages and fitness records.

Mozilla acknowledged the j2me.js plan as one of its exploratory routes for making "a few key" Android apps available in its Firefox Marketplace.

"We support and strive for a better Web experiences on mobile," the nonprofit organization said in a statement. "However, we believe that starting with the Web as the platform and adding support for native elements as needed, rather than the inverse, is the most open way to reach that goal."

Browsers appear to be a second priority for mobile software at Apple and Google. Apple helped pioneer the modern mobile Web with its introduction of the Safari browser for iOS in 2007, and Google has become even more active with its Chrome browser for Android. But Safari only lasted a few months last decade as the way Apple suggested programmers bring their software to iOS, and at May's Google I/O conference for developers, Chrome and Web programming were barely mentioned in the keynote speech compared to Android.

Programmers got the message. The Web remains important technology, but app developers are flocking in droves to build apps that run natively on iOS and Android. iOS boasts 1.5 million apps, and Android has 1.8 million, according to app analytics tracker App Annie.

Firefox OS statistics are hard to compare directly since websites can be reached directly and often are geared for all mobile operating systems. But Firefox on mobile -- Firefox OS and the Android version of Firefox combined -- accounted only for 0.4 percent of smartphone and tablet browser usage in May, according to analytics firm StatCounter.

J2me.js and the WhatsApp problem

One crucial program is WhatsApp, the text-messaging tool Facebook acquired for $19 billion in 2014. WhatsApp is popular as a way to send messages without incurring the fees carriers often charge for traditional text messages.

So far, there's no sign of WhatsApp for Firefox OS -- but that's something j2me.js could fix. Gal specifically highlighted WhatsApp in a 2014 talk about j2me.js at a JavaScript conference that was just published online in May.

"Messaging apps like WhatsApp are very popular," Gal said. "In some parts of the world...if you don't have them on your phone, nobody's going to buy it." But it's very hard to convince messaging-app developers to create Web-specific versions, he said. Line is available for Firefox OS, but Viber and WhatsApp aren't.

Enter j2me.js. To explain how it works, though, here's a little background.

Mozilla's project takes its name from Java 2 Micro Edition, which Java creator Sun Microsystems successfully spread to countless phones starting more than a decade ago. Modern smartphones run rings around those lower-end "feature phones" now, but Java did help programmers bring their software to the huge variety of phones on the market before iOS and Android grew dominant. Many apps -- including WhatsApp -- are built for Java.

Crucial to Java is a software layer called a Java virtual machine (JVM) that let the apps work regardless of the components in the phone, such as a Qualcomm or Intel processor, for example. It's an idea sufficiently useful that Google adapted it for Android's foundation, though it didn't use J2ME.

Translating Java

The JVM is essentially a computer unto itself. It runs the Java program and translates it into instructions the underlying computing device can understand. What Gal and his Mozilla colleagues did was create a JVM that runs on Firefox's ordinary JavaScript engine. That provides a bridge to get a Java app onto a browser foundation.

Screenshot by Stephen Shankland/CNET

Gal built j2me.js to run Java apps. But in principle the approach could be adapted to run their cousins, Android apps.

What's not clear is whether Facebook would look fondly on that kind of plan. If performance is bad or if apps don't look or work quite right, users might well blame WhatsApp even if it's not at fault. That could hurt a company's brand. And as happened with instant-messaging software like Yahoo Messenger and AIM on personal computers a decade ago, a company could well block software it doesn't like so it doesn't work on the service.

Facebook declined to comment on Mozilla's technology or its plans for supporting Firefox OS.

It's a long way toward the kind of robust app catalog found in iOS and Android. Even if Mozilla builds its j2me.js bridge to Android, it's only one step on the path to success for Firefox OS. But at least it's a step forward.