Myths about JavaFX, Android, and J2ME

June 8th, 2009 by jeremychone

At JavaOne, Larry Ellison has made some very encouraging statements about Oracle’s commitments to Java, JavaFX, and the mobile developer market. It is certainly good news that Oracle (i.e., Larry) sees the significance of the Java platform in its integrality. However, there are many misunderstandings about the relationship between Java, JavaFX, and Android that even confuse the new Java owner. Here are some clarifications.

1) JavaFX is NOT Java.

Obviously, from a marketing standpoint, JavaFX is branded as Java; however, technically JavaFX is a language by itself, which happens to be compiled into Java bytecode and run on a Java VM. JavaFX is similar to Groovy or JRuby, minus the dynamic part (see #2). For example, introspecting a JavaFX object from Java requires some tricks since JavaFX Object/Class definitions do not map directly to those of Java Object/Class. (Note: Sun has been trying to brand JavaFX beyond the JavaFX Language itself, but so far most developers see JavaFX as the language)

2) JavaFX is NOT a scripting language.

Even though it is called JavaFX Script, JavaFX is NOT a scripting language (in the dynamic sense). JavaFX code gets compiled to Java bytecode at design time. So, JavaFX is similar to Flex (except for the XML-UI part). Note that JavaFX started as a scripting language in Sun Labs, but quickly became a compiled language (probably for performance reasons). Sun keeps using the term “JavaFX Script” to distinguish the language from the JavaFX brand and to avoid using the word “language,” which would make it too obvious that JavaFX is another language all together.

3) Android is NOT a Java-based device.

Here again, some confusion could come from Larry’s keynote address. Some might believe that Android is Java-based and that it runs Java. However, Android is NOT Java based; it is Linux based. Google Android SDK converts Java bytecode to Android more optimized Dalvik VM bytecode. Thus the developer codes with Java, but the device does not run Java (kind of similar development experience to GWT, which cross-compiles Java code to JavaScript/AJAX). While it is possible to have Java VM for an Android phone, an application built with Android SDK does not run on Java when executing on the device. By the way, I still have not found JavaVM for my G2/HTC-Magic.

4) JavaFX cannot run on Android without a Java VM.

I would LOVE to be proven wrong (with an example) on this one. This is a discussion I had with my friend @cromwellian about getting JavaFX on Android. In short, the only practical way to get Java FX on Android would be to have a JavaVM on Android. The Android cross-compiling trick would be pretty complex to extend to JavaFX. As stated above, JavaFX is not only a library, but a whole different language, which gets compiled to Java bytecode. So the Android compiler will have to do quite a bit of work to move a Java/JavaFX application to a non-Java VM. It’s not impossible, but hard. GWT2 hard, I think. So, to recap, you can run JavaFX on Android, but you need a JavaVM (apparently JavaFX on Android has been demo in JavaOne -see 2:30-)

5) Java is NOT on most devices [that matter].

Sun likes to say that Java is on billions of devices (see 0:54). While mathematically probably true, practically, developers do not really care about Java for mobile. These days it’s all about iPhone, Android, Plam Pre, and mobile Web (not even Windows mobile). Most of these high-profile phones do not have Java out of the box, and getting a Java runtime can even be challenging. For example, there is no JavaVM out of the box on iPhone, Android G2/HTC-Magic, and Treo 750 WinMobile (I could not find one on my old Treo 750 WinMobile). And for the rest—well, the J2ME market is very fragmented. It is really hard to measure your reach when you develop a Java application for mobile devices. And the ironic part is that since JavaFX needs the latest and greatest JavaVM to run, it does not even run on the billions of billions of J2ME devices anyway. So, in a way, Sun has been resetting the clock with JavaFX for their mobile market. They still have the device manufacturer’s relationships but they do not have the devices anymore.  Some disagree with these statements noting that Java is on all Nokia and most Sony-Ericsson devices (see Jehtro’s comment)

As a software Architect/Entrepreneur, I truly like and use Java a lot, but I hate Kool-Aid. I really wish that Java and JavaFX will be successful on the mobile and PC market, but as a community, we need to assess the current state realistically if we want to accomplish our vision. That aside, I would agree with Scott: if Larry managed to convince Steve to put Java on iPhone (at 0:26), it would definitely be a game changer (however, this would be against Apple’s Wall policy).

As a side note, I am sure that the Open Office team got very excited when Larry told them they should port their application to JavaFX. Flying pixels should rule the world!

If you liked this article +1 on HN and R-Tweets are greatly appreciated.

27 Responses to “Myths about JavaFX, Android, and J2ME”

  1. Jethro Says:

    Great post until point 5 IMO.

    The fact Java is not on the first G-Phone, the iPhone or new Pre, is no indication its not on most devices.

    In fact, there is Java on practically all Nokia’s (biggest handset provider) and on most Sony Ericsson and Samsung devices.
    These devices have a much larger market share than iPhones, GPhone and Pre (which has only just come out).

    Other than the iPhone, it probably wont take long before we see Java on the other ‘new’ devices either.

    If your serious about mobile development, Java has, and will continue to be, very important and give greatest reach. With JavaFX, I can only see this being even more important (if Sun-Oracle get it all right that is).

    Developers most certainly *do* care about Java for mobile, as it makes our job way easier.

  2. Jeremy Chone Says:

    @Jetho Thanks for feedback, I just annotated the article to reference to your comment. BTW, are those Java devices support JavaFX?

  3. Jeremy Chone Says:

    Interesting speculation on why Google/Android is not using J2ME/Java on Android. Here is some speculation on why:

    Thanks to nswanberg for his comment on HN.

  4. Dan Says:

    Worth pointing out that Java (in its J2ME incarnation) is on pretty much every BlackBerry out there, which just happens to be the world best-selling smartphone.

    Yeah, RIM’s app store concept sucks/is non-existent, but it’s coming and if you’re dedicated, you can work around that.

  5. Jeremy Chone Says:

    @Dan Can J2ME/BlackBerry run JavaFX?

  6. Myths about JavaFX, Android, and J2ME | Linux Articles Says:

    [...] is the original:  Myths about JavaFX, Android, and J2ME Tags: certainly-good, confuse-the-new, fbi, food-containing, java-obviously, larry, [...]

  7. Bob (Buffone) Says:

    @Jethro – I go to JavaOne every year and there are 10 mobile phone vendors there with Java on there phones and Java is on all blue ray devices and on chips and on the desktop for a total of 10 billion devices with Java on it.

    There are probably that many devices with Java but it doesn’t matter. The problem is all the versions and capabilities are different for each device and it is impossible to distribute software easily to the devices.

    I can’t even get JavaFX to run in the browser on my machine because for some reason the latest JVM won’t install, runs fine as a desktop application but not in the browser.

    So it doesn’t even matter if there are or not that many devices, Java as a language is awesome I think but as an end-user application platform it still has a ways to go.

  8. Peter Burns Says:

    Point 3 is true in only the most pedantic sense. True, Dalvik doesn’t run Java bytecode, but the only code it runs out of the box is Java bytecode compiled to a .dex file. The only time this makes a difference is if you’re generating bytecode at runtime, or if a feature doesn’t make its way to Dalvik.

  9. Jeremy Chone Says:

    @Peter if it does not have a JavaVM it is not Java based. It’s like saying GWT is Java based.

    BTW, I would love to be proven wrong on #4.

  10. Jethro Says:

    While JavaFX doesn’t run on all the current phones that have Java installed (which is simply because they have no update mechanism built in and that J2ME has been quite fragmented which has led to all sorts of problems – as Bob pointed out), I would expect to see it starting to appear on devices (such as Nokia’s and Blackberry’s) over the next year or so.

  11. Google App Engine SDK for Java « c# to javascript, actionscript Says:

    [...] Google Android SDK cross-compiles Java code to Android native bytecode. Comments [...]

  12. » JavaFX, Android, and J2ME Says:

    [...] [...]

  13. Russell Stuart Says:

    Most small devices (such as phones, including Android) are based on ARM. A now mandatory part of the ARM architecture is hardware based Java bytecode interpretor.

    This means Ellison was right. On small platforms, Java is more or less ubiquitous.

  14. k s Says:

    J2ME is on all/most nokia, sony ericsson, samsung, lg, motorola, blackberry, … that would give it a 75%-80% worldwide market share. So its the no 1 platform for developing on it games, business apps, …

  15. Jeremy Chone Says:

    @Russell I am confused, are you saying that Android is Java based?

  16. Google Android: “Hallo Welt” in 30 Minuten » Says:

    [...] der offiziellen Android-Seite findet man zunächst eine gute Architekturübersicht. Außerdem sind Mythen über Android, JavaFX und J2ME sehr [...]

  17. andry12 Says:

    And you can find out what phones or other mobile devices are running Android OS? Phones that are running Linux of course not, but linux is linux, it works even on mobile devices, I think that the phones with the Android OS will be as reliable!

  18. Mobile Application Development Says:

    If you say that there is no Java VM going with an iPhone – how do I install Java apps on it? I’ve read about many people who do it.
    Do I have to find and setup a Java VM first, and only then I may install java on the device?

  19. Víctor Orozco (tuxtor) 's status on Monday, 14-Sep-09 06:14:25 UTC - Says:

    [...] Interesante articulo respecto a JavaFX [...]

  20. asj Says:

    Actually, Java ME is on most devices in the world. The problem is that here in the US most people focus on Blackberry (which has a compatible Java ME environment so J2ME apps do run on it) and iPhone, while outside the US, and especially in Asia, most apps are actually Java ME and run on the Nokias, Sony’s, etc in those countries.

    Also, since people write in Java for the Google Android environment, one could say that IS Java, or at least Java compatible. I don’t care about the “brand”, simply the programming environment, as do all developers.

  21. asj Says:

    Btw, just so you know, the number one mobile browser in the world is a Java ME app, called Opera Mini. This runs on almost any cellphone, and is one of the most successful J2ME apps out there.

  22. iphone application developers Says:

    I am also facing the problem with Java in my iPhone. I think we have to setup VM first and then try to install it.

  23. JavaFX, Android, and J2ME « createTank Says:

    [...] [...]

  24. Blog Excilys » JavaFX a-t-il un avenir ? Says:

    [...] Myths about JavaFX, Android, and J2ME : « Java is NOT on most devices (that matter) », entre autres… [...]

  25. bbqchickenrobot Says:

    JavaFX running on Android:

  26. Bryan Young Says:

    I know this post is nearly a year old now, but I didn’t see this pointed out in the comments, so I thought I’d add it: Point 4 is not strictly true. Android doesn’t compile Java source to dalvik. It compiles Java class files to dalvik. This makes it very UNLIKE GWT which parses Java source code and generates JavaScript. Unlike GWT, Android can support languages other than Java as long as they generate byte code. That said, if its anything like trying to run a Scala app, it may not be worth the trouble.

    It makes me wonder how that Sun demo from 2008 was done. At the time, I assumed Android ran JavaME, but I’m guessing now that wasn’t the case. It was a little deceptive of them not to explain at the time.

  27. Jeremy Chone Says:

    @Bryan, Yes you are right, technically they are different. Once take the source and the other the java bytecode. Now, at the high level, same concept, allow Java developers to program in java and automatically port the code/bytecode to other runtime (without Java VM).

    About JavaFX, does not matter, it is dead now.