4 Replies Latest reply on Dec 18, 2007 5:17 AM by peterent

    Flex and Java


      What is the easiest way to invoke Java methods from within Flex?
      Suppose I have a set of jars and I require Flex events to make a call to certain methods from one of these jars.
      As soon as the method returns with the data (say in a HashMap) I have to populate a combo box.

      Quick response is highly appreciated...

      Sandeep Phukan
        • 1. Re: Flex and Java
          peterent Level 2
          Flex generally interacts with Java running on a server as part of a J2EE application system like ColdFusion, WebSphere, Tomcat, WebLogic, etc. This is done primarily through the Flex RemoteObject data service.

          Think of Flex like any other web application software, such as PHP or JSP - except the client has much greater control over the state of the interface. All interaction with the outside world is done via the browser and to a server.
          • 2. Re: Flex and Java
            FlexBug Level 1
            Hi Peter,

            Thanks for the quick response. The problem is the Java classes I have are not running as a service. It appears I have to do that now and then invoke these services via Flex. I cant understand why isnt direct interfacing with Java allowed. I mean this way I wouldnt have to think about Web Services and all....

            Sandeep Phukan

            • 3. Re: Flex and Java
              FlexBug Level 1
              As for example assume that I have a Java method that lists down all directories and subdirectories in a location.
              I might want to call this method via Flex instead of taking pains of exposing it as a service or doing the same in AS.

              Sandeep Phukan
              • 4. Re: Flex and Java
                peterent Level 2
                It is not possible for the Flash Player to read and write local files - even if it were possible to call out to Java functions. The only way to read and write local files is to use AIR and that has its own, platform independent, File classes. I have used Java classes to read and write local files and the AIR classes are even easier to use.

                It is possible to reach beyond the Flash Player using the ExternalInterface class and making calls to JavaScript functions defined by the HTML wrapper.