Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Manipulating a Third-Party Java Application from another Java Application

Reply
Thread Tools

Manipulating a Third-Party Java Application from another Java Application

 
 
travis.troyer@gmail.com
Guest
Posts: n/a
 
      04-09-2007
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

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      04-09-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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()

HTH

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

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.asp...neral/200704/1

 
Reply With Quote
 
 
 
 
Travis Troyer
Guest
Posts: n/a
 
      04-09-2007
On Apr 9, 11:27 am, "Andrew Thompson" <u32984@uwe> wrote:
> (E-Mail Removed) 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

 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      04-09-2007
Travis Troyer wrote:
>> (E-Mail Removed) 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.asp...neral/200704/1

 
Reply With Quote
 
Travis Troyer
Guest
Posts: n/a
 
      04-09-2007
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?

 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      04-10-2007
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

 
Reply With Quote
 
angrybaldguy@gmail.com
Guest
Posts: n/a
 
      04-10-2007
On Apr 9, 11:48 am, "Travis Troyer" <(E-Mail Removed)> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Manipulating the Windows Environment from Java Gilbert Ostlethwaite Java 1 12-06-2006 04:13 PM
To increase speed on manipulating big arrays in Java with minimal bounds checking, ... Casey Hawthorne Java 16 09-01-2005 06:33 AM
Java/Vb Script syntax for manipulating word client side Yohancef Chin ASP .Net 0 12-04-2003 09:47 PM
Manipulating control in one frame from another frame, how? Søren M. Olesen ASP .Net 0 11-13-2003 05:37 PM
Manipulating a User Control from another User Control Tom Rowton ASP .Net 2 08-01-2003 08:18 PM



Advertisments