Manipulating a Third-Party Java Application from another Java Application

Discussion in 'Java' started by travis.troyer@gmail.com, Apr 9, 2007.

  1. Guest

    I have an existing third party application that is written in Java,
    and then run via an exe wrapper. I'm trying to automate certain user
    input to this application (and retrieve the text from specific
    controls to monitor progress, output, etc). Normally I would do this
    using Window's API function such as FindWindow, GetWindowText,
    SendMessage, etc. However, none of these functions will work with the
    third-party java application, as I can get only the handle of the
    parent JFrame, but the other controls seem to have no handles.

    Is there anyway to manipulate or communicate with the controls on the
    third party application from my own Java application? I've done a lot
    of searching and reading, but have yet to find anything that directly
    applies to what I'm trying to do.

    Any insight or assistance is appreciated.

    Thanks,

    Travis Troyer
     
    , Apr 9, 2007
    #1
    1. Advertising

  2. Andrew Thompson, Apr 9, 2007
    #2
    1. Advertising

  3. On Apr 9, 11:27 am, "Andrew Thompson" <u32984@uwe> wrote:
    > wrote:
    > >..I'm trying to automate certain user input to this application ..

    > .
    > >..I can get only the handle of the
    > >parent JFrame, ..

    >
    > See JFrame.getContentPane().getComponents()


    Thanks for your reply. That should work for me, if I can figure out
    how to access the JFrame in Java. To clarify my initial post, I know
    how to use Windows API in VB and C# to get a window handle, but I'm
    not sure how I would use Java to get the third-party JFrame and then
    use it in my program.

    Thanks,

    Travis
     
    Travis Troyer, Apr 9, 2007
    #3
  4. Travis Troyer wrote:
    >> wrote:
    >> >..I'm trying to automate certain user input to this application ..

    ..
    >> See JFrame.getContentPane().getComponents()

    >
    >Thanks for your reply. That should work for me, if I can figure out
    >how to access the JFrame in Java. To clarify my initial post, I know
    >how to use Windows API in VB and C# to get a window handle, but I'm
    >not sure how I would use Java to get the third-party JFrame and then
    >use it in my program.


    The best strategy might be wo 'unwrap it' from the .exe
    and instead call the main() from within your own code.
    Then you can probably locate the JFrame from within
    your app., and keep a reference to it.

    What does the manufacturer recommend?

    --
    Andrew Thompson
    http://www.athompson.info/andrew/

    Message posted via JavaKB.com
    http://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1
     
    Andrew Thompson, Apr 9, 2007
    #4
  5. On Apr 9, 1:16 pm, "Andrew Thompson" <u32984@uwe> wrote:
    > The best strategy might be wo 'unwrap it' from the .exe
    > and instead call the main() from within your own code.
    > Then you can probably locate the JFrame from within
    > your app., and keep a reference to it.



    After looking at the directory contents, I may have found the two jar
    files used by the application, but I'm unable to launch them. I
    received a "Failed to load Main-Class manifest attribute." error.
    Based on the configuration file I found on the wrapper, I tried to
    modify the main class location in the jar file, but no luck. I'm
    honestly not sure how I would call the main function from within my
    own code as you suggest (my Java experience is limited, I just thought
    this process might be easier using Java, since the third party
    application is written in Java)...

    > What does the manufacturer recommend?


    The manufacturer has no recommendations, we're basically on our own.

    Using Winspector, I was able to get the handle and related information
    for the JFrame. Is there no easy way to get the handle from Java, and
    then access this JFrame?
     
    Travis Troyer, Apr 9, 2007
    #5
  6. Travis Troyer wrote:
    ..
    >...(my Java experience is limited, ...


    *

    >> What does the manufacturer recommend?

    >
    >The manufacturer has no recommendations, ..


    Why not? Lost the power of speech and developed
    dyslexia due to some freak accident, have they?

    >Using Winspector, I was able to get the handle and related information
    >for the JFrame. Is there no easy way to get the handle from Java, and
    >then access this JFrame?


    * If I was over at your dev. environment, it would take
    but a few minutes to sort where the main was. So,
    "heck yeah it's easy". Perhaps you should hire an
    *experienced* Java programmer/consultant for this
    task.

    --
    Andrew Thompson
    http://www.athompson.info/andrew/

    Message posted via http://www.javakb.com
     
    Andrew Thompson, Apr 10, 2007
    #6
  7. Guest

    On Apr 9, 11:48 am, "Travis Troyer" <> wrote:
    > On Apr 9, 1:16 pm, "Andrew Thompson" <u32984@uwe> wrote:
    >
    > > The best strategy might be wo 'unwrap it' from the .exe
    > > and instead call the main() from within your own code.
    > > Then you can probably locate the JFrame from within
    > > your app., and keep a reference to it.

    >
    > After looking at the directory contents, I may have found the two jar
    > files used by the application, but I'm unable to launch them. I
    > received a "Failed to load Main-Class manifest attribute." error.
    > Based on the configuration file I found on the wrapper, I tried to
    > modify the main class location in the jar file, but no luck. I'm
    > honestly not sure how I would call the main function from within my
    > own code as you suggest (my Java experience is limited, I just thought
    > this process might be easier using Java, since the third party
    > application is written in Java)...


    What, exactly, did you find and what did you try? It's not clear from
    your description what you had no luck with.

    If you can find out what the name of the "main" class is, you can run
    that class's main method directly, either from the command line or
    from another java program. It sounds like you tried running the
    individual jars, and none of them have a preconfigured main class,
    which probably means the name of the class in use is in the EXE
    launcher somewhere, or in one of its config files.

    > > What does the manufacturer recommend?

    >
    > The manufacturer has no recommendations, we're basically on our own.
    >
    > Using Winspector, I was able to get the handle and related information
    > for the JFrame. Is there no easy way to get the handle from Java, and
    > then access this JFrame?


    The win32 handle for the application's window is going to be close to
    useless if the application uses Swing (which it sounds like it does),
    since Swing doesn't use the Win32 API for much. All drawing and
    window components in a Swing application happen inside the JVM that
    owns the window.

    In order to navigate a Swing application's component hierarchy you
    need to be able to access the objects in that JVM. That either means
    running your own code in that JVM or attaching a java debugger to it.
     
    , Apr 10, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ezhil
    Replies:
    1
    Views:
    640
    Bruce Barker
    Sep 19, 2005
  2. roy
    Replies:
    2
    Views:
    538
  3. crash.test.dummy
    Replies:
    0
    Views:
    340
    crash.test.dummy
    Mar 15, 2006
  4. Ben Finney
    Replies:
    6
    Views:
    305
    Serge Orlov
    Jun 15, 2006
  5. Daz
    Replies:
    5
    Views:
    333
Loading...

Share This Page