cancel
Showing results for 
Search instead for 
Did you mean: 

How do you attach to a java application?

HarryWiggans
Level 3
I have a java application I created and I am trying to attach to and interact with it without success. I have already setup JAB.

If I change the application model and my object so that I launch the java application and then interact with it then everything works just fine.
i.e. changing the application model to "My application is launched from an executable file"

However, if I change the application model to "My application will already be running - I want to attach to an existing instance" and change my object so that it attaches to the java application then it fails with a popup message saying....

"There are no Java elements matching the query"

In the navigation stage that I am using to attach to the application I am using the window title and the process name. For process name I have entered "Javaw".

The funny thing is that it appears to be attaching to something. I don't see an error saying it's not attaching. For instance if I change something like the application's title then I get an error message like ...
"Target application could not be identified"

So it's like it is finding the right application but then when it actually tries to interact with it, it can't.
Everything works perfectly if I launch the application. It interacts with all the java components I want it to just fine.

Any thoughts on what I could be doing wrong with this?

------------------------------
Harry Wiggans
------------------------------
7 REPLIES 7

John__Carter
Staff
Staff
Sounds like you're almost there if it is attaching to something, and the fact that you can launch and spy means you've hot JAB working. Try attaching with only the window title or onlt the process name. MS Process Explorer can be a useful tool when trying to understand the exes on your machine.

------------------------------
John Carter
Professional Services
Blue Prism
------------------------------

Hi John and thanks for the suggestions. So far I have not been successful in using only the window title nor only the process name. I also downloaded the MS Process Explorer but as far as I can tell it's saying the process name is the same as I had before, "javaw". I did try looking through videos online as well as documentation but surprisingly little cover doing an attach to a java application. I do feel that I am close as you mentioned but this one last piece seems to be a barrier.

------------------------------
Harry Wiggans
------------------------------

Hmm. So you can attach, sort of, but elements that were previously created after launching can no longer be highlighted? What about when you spy a new element after attaching?

------------------------------
John Carter
Professional Services
Blue Prism
------------------------------

Hi John. If I launch the application, then I can spy new elements with ease. No problem at all. 

It seems that if I attach, I can not even spy new elements. What's curious about it is that the java application's main window is picked up but nothing inside the window is identifiable at all. 

while attached I then tried changing spy modes to see if anything would be detected and it gave the exact same behavior with win32, aa, etc. I guess that part is not too surprising since there's only java elements on this page. 

As a test I changed to use the application navigator, just to test if it could pick up the elements inside. That's usually a failsafe, when it showed the tree for the application it only showed the main window and menu items. Nothing inside was even picked up.

All that would make me think something is wrong with the JAB setup, however, if I change so that the application is launched I can spy new elements, no problem, my VBO runs perfectly and can identify each java element on the page and interact with them accordingly.

------------------------------
Harry Wiggans
------------------------------

Hi John. Sorry if this message appears twice, I wrote this up and his "send" but nothing happened earlier. To answer your question, If I launch then I can spy new elements. If however I attach then I can't spy new elements.

When I attach and then try to spy it can detect the java application's window but not the java elements inside the window. I then as a test tried changing the spy mode to win32, AA, etc and all other spy modes gave the same behavior. I guess that should not be too surprising since there are only java elements in the application.

The funny thing is I then tried, just as a test, to see what happened when I tried to spy using the "UI Automation Navigator".  It showed that it detected the window but just the window and the file menu and generic things like that. Nothing else, none of the java elements show up in the tree view of the "UI Automation Navigator".

So all this would make me think that the JAB is not configured correctly but the reason I don't go down that path is that if I launch the application then I can spy all the java elements with no issue whatsoever and I can spy new elements in the application.

------------------------------
Harry Wiggans
------------------------------

Not sure why my reply is not appearing. Will try one more time. This is what I wrote earlier last week in response....

Hi John. If I launch then I can spy new elements. If however I attach then I can't spy new elements.

When I attach and then try to spy it can detect the java application's window but not the java elements inside the window. I then as a test tried changing the spy mode to win32, AA, etc and all other spy modes gave the same behavior. I guess that should not be too surprising since there are only java elements in the application.

The funny thing is I then tried, just as a test, to see what happened when I tried to spy using the "UI Automation Navigator".  It showed that it detected the window but just the window and the file menu and generic things like that. Nothing else, none of the java elements show up in the tree view of the "UI Automation Navigator".

So all this would make me think that the JAB is not configured correctly but the reason I don't go down that path is that if I launch the application then I can spy all the java elements with no issue whatsoever and I can spy new elements in the application.

------------------------------
Harry Wiggans
------------------------------

Sorry for replying with basically the same message 3 times. That was unintentional. Over a couple of days I tried replying to the message and nothing appeared then all of a sudden one day I see that all 3 almost identical messages appeared. Sorry for cluttering the board. 

Anyhow, I did want to report that I did resolve this, well sort of. I had tried launching the java application and attaching to it which was not working. My ultimate goal however was to have Blue Prism launch the java application from a browser by clicking on a link and then attaching to it.  So I thought I would try just double clicking on the application to test attaching to it first. That was not working. It never occurred to me to test out my ultimate goal, i.e. have blue prism click on a link on a web page and launch the java application and then attach to it. Eventually I tried that and it worked perfectly. So in a way it's good, because I have what I ultimately wanted working, but just out of curiosity sake I am surprised that double clicking on the java application and trying to attach did not work. Anyhow I think I have what I wanted now. Thanks.

------------------------------
Harry Wiggans
------------------------------