Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Manipulating a Third-Party Java Application from another Java Application

Thread view: 
travis.troyer@gmail.com - 09 Apr 2007 15:57 GMT
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
Andrew Thompson - 09 Apr 2007 16:26 GMT
>..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

Signature

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

Travis Troyer - 09 Apr 2007 16:58 GMT
> travis.tro...@gmail.com wrote:
> >..I'm trying to automate certain user input to this application ..
[quoted text clipped - 3 lines]
>
> 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
Andrew Thompson - 09 Apr 2007 18:16 GMT
>> travis.tro...@gmail.com wrote:
>> >..I'm trying to automate certain user input to this application ..
..
>> See JFrame.getContentPane().getComponents()
>
[quoted text clipped - 3 lines]
>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?

Signature

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

Travis Troyer - 09 Apr 2007 19:48 GMT
> 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?
Andrew Thompson - 10 Apr 2007 04:44 GMT
..
>...(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.

Signature

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

angrybaldguy@gmail.com - 10 Apr 2007 06:43 GMT
> > The best strategy might be wo 'unwrap it' from the .exe
> > and instead call the main() from within your own code.
[quoted text clipped - 10 lines]
> 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?
>
[quoted text clipped - 3 lines]
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.