5 Replies Latest reply on Jan 4, 2009 6:20 AM by FlexNewbie2009

    Flex/AIR + Java Integration

      Hello everyone,

      I am a Flex+AIR newbie and just wonder if it's possible to develop a layered FLEX/AIR application where only the presentation layer is built in Flex and the business logic / DB access layer is Java. But not in a web or J2EE context with a remote server.

      The scenario I have in mind is the following:

      1. A Flex application is deployed on the user's local machine via AIR.
      2. The user starts the application. So far so good.
      3. On startup the application performs a method call on a Java class located on the user's local machine's class path.
      4. The method call triggers a multithreaded Java engine to get started.
      5. The Flex app "talks" to the Java engine and vice versa.

      Several questions arise here:

      a: How can a Flex app "speak" to Java classes? Is it possible at all?
      b: I heard of a "RemoteObject" tag. Is this the way to go?
      c: Can a Flex app start a process on the local machine (e.g. a JVM)?
      d: Is it possible to deploy the Java JAR file "piggy-back" with the Flex/AIR app?

      Or e: Maybe I am on a totally wrong track. Can anybody suggest a better solution?

      It should be possible since Bruce Eckel of Adobe writes: "However, a Flex UI is not limited to communicating with a server. It can also communicate with a local application. Thus, you can create an application in any language you prefer, even a dynamic language like Python or Ruby, and use Flex to build a beautiful UI." ( http://www.adobe.com/devnet/flex/articles/hybridizing_java_08.html)

      Thanks in advance!

      Best Regards,
        • 1. Re: Flex/AIR + Java Integration
          I have the exact same needs but after voicing the need for the ability to invoke a Java class for a year I still haven't heard a definitive answer.
          • 2. Re: Flex/AIR + Java Integration
            FlexNewbie2009 Level 1
            This is not the answer I was hoping for. Thanks anyway.

            If you're right then Bruce Eckel and other Adobe evangelists might turn out to be just gossips who heavily promote an immature product (Flex/AIR) while bashing other established technologies (Java). I hope I am wrong on this point.
            • 3. Re: Flex/AIR + Java Integration
              I've got similar research going on for a project that sounds similar (multi-threaded java app with an AIR-based GUI). This is by no means a definitive answer but what I (think) I've found so far:

              a. I've found something called merapi ( http://merapiproject.net/) that appears to let an air app and a java app exchange AMF messages w/out the use of blazeDS and a J2EE container. A caveat though: I haven't tried it yet and I'm having trouble getting access to the code.

              b. don't know yet

              c. I haven't yet found a way to do that. My current thinking is that my multi-threaded java application will have to start first and then launch the AIR app via something like ProcessBuildier or Runtime.getRuntime().exec(). This creates some additional problems but it's the only way I can find so far.

              d. don't know yet
              • 4. Re: Flex/AIR + Java Integration
                FlexNewbie2009 Level 1
                Thanks pqaid for your reply.

                a) The Merapi project looks quite interesting. I quickly read through their web site and watched some videos. It seems to provide answers to some of my questions. I will have to invest more time though.

                c) At least in my case the AIR app has to start first (i.e. the user starts it by double-clicking the desktop icon). So the AIR app has to start the Java app (vice-versa would be simple, indeed).

                It's a bit off-topic but what strikes me is the abysmal memory usage of AIR apps. I tried the TourDeFlex demo and after having tried a few components memory usage went up to 130+ MB. Quite a lot for an application that does almost nothing.

                • 5. Re: Flex/AIR + Java Integration
                  FlexNewbie2009 Level 1
                  I am browsing through the Merapi forum and what I found so far sounds discouraging:


                  To my knowledge, there is no way an AIR application can start an OS application.