Skip to main content

HELP: Running Applications that use OLE/ActiveX through JAVA

2 replies [Last post]
karukun
Offline
Joined: 2006-07-24
Points: 0

I'm developping testing software that mostly involves automation. Although I would prefer to write all the testing code myself, I have been asked to use some existing utilities. One of these utilities runs some database queries and then creates a COM object for the program I'm supposed to test. I calls a method in that program ( that performs an action on some databases ), and then exits. The utility is a very simply exe. When I run the utility from the command line, it starts a thread that runs for about 10 seconds, after which it is finished and the thread exits.

Now, I have a testing suite program that's built with Java. I've tried to have the program call the utility through Runtime.getRuntime().exec(...), but when I do this, the utility never terminates. I can see CPU usage spike and then go flat. The utility process is still running in Task Manager, and it isn't until I reset the virtual machine or exit my program that the process spikes CPU usage again (it writes the changes to the database) and finally terminates.

I've had this problem a few times before. I'll have an exe that uses some sort of automation through COM objects, and whenever I try to run that exe from Java, it chokes and never finishes. Do I have to register my Java program somehow? Maybe change a setting in Windows?

OS: Windows 2000
Java Version: 1.5.0_06

I don't know if this matters or not, but I have used a Java-COM bridge called JACOB to do automation from Java, and whenever I do it straight from Java using JACOB (instead of an exe), the automation works perfectly fine. It's only when I use the middle-man exe that things go wrong.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
olsonje
Offline
Joined: 2005-08-10
Points: 0

It's not waiting for some sort of user based interaction is it?

Are you waiting for the process via the waitFor method?

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Process.html in case you want to readup more on it.

karukun
Offline
Joined: 2006-07-24
Points: 0

The utility definitely isn't waiting for any user interaction, and I am using the waitFor() method. The waitFor() method simply never returns, unless I close my Java program or restart the virtual machine. I find it rather strange. I tried running the utility without calling waitFor(), but it didn't make a difference.