2 Replies Latest reply on Aug 5, 2009 10:21 AM by jimmyoneshot

    Strange class error when using java


      I've been attempting to use java.awt.robot to simulate a key press when a button is clicked however I'm getting a couple of errors that I can't figure out but I'm not so good when it comes to scripts. When the button "LetterButton" is pressed it should simulate a keypress, ideally to the desktop/operating sytem but the errors I'm getting are:-


      1071: Syntax error: expected a definition keyword (such as function) after attribute public, not static.

      1084: Syntax error: expecting rightbrace before leftbrace.

      1131: Class must not be nested.


      Here's the code:-














      <?xml version="1.0" encoding="utf-8"?>




      http://www.adobe.com/2006/mxml" layout="absolute"



















      public class

      Main {



      public static void

      main(String[] argv) throws Exception {


      Robot robot =



















      <mx:VBox x="359" y="262" horizontalCenter="0" verticalCenter="0"




      <mx:Button id="LetterButton" label="Button" click=""




      <mx:TextInput id="txt"






        • 1. Re: Strange class error when using java
          Gregory Lafrance Level 6

          If this post answered your question or helped, please mark it as such.


          You can't have Java in Flex apps. You would need to write the Java program as a separate command line Java app, and then when the user in Flex app does something, write out a file that just acts as a flag file.


          The Java app would be running siltently in the background, checking for the existance of the flag file. When it detects it, the Java app deletes the flag file and simulates the keystroke.


          Not a pretty solution, but an option.

          1 person found this helpful
          • 2. Re: Strange class error when using java
            jimmyoneshot Level 1

            Sounds tricky. I may ask them to look for an alternative way of doing it as Java really isn't my thing, I'm merely just a flex beginner at the moment.


            The reason I've been looking for this is that my app will be installed on a digital tv that also has a system connected to it using a Linux operating system so the user can switch between watching digital tv and the application seamlessly and at the moment a Linux professional who I'm working with has the Digital TV bound to the F12 key which is bound to a handheld remote control (being a tv there is no keyboard, just an 'air mouse' and the remote control).


            So my client and my Linux guy have asked me to come up with a way of getting the app to communicate with the desktop/operating system. I have seen flex apps in the past where a user can drag and drop videos on their desktop into an air application from which they will be played so I thought it would be possible to interact with the exteral OS/Desktop from within an AIR app by using just flex but it doesn't seem so easy through my research.


            Thanks for your help though.