Manipulating a Third-Party Java Application from another Java Application

T

travis.troyer

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
 
T

Travis Troyer

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
 
A

Andrew Thompson

Travis said:
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
 
T

Travis Troyer

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?
 
A

Andrew Thompson

Travis Troyer wrote:
..
...(my Java experience is limited, ...

*
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.
 
A

angrybaldguy

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.
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,156
Latest member
KetoBurnSupplement
Top