Running multiple instances of the same Java executable/jar

Robertics78

New Member
Hi all,

I wondered if it's possible to run multiple instances of the same Java executable on one server.
More or less I'm starting a JAR-file, which starts a JavaW-session (JavaW.exe).

It's possible to run multiple sessions of this JAR on the same server (and interact with them individually), but I wondered if there's a way to do the same as is done with Excel instances, where you can address each individual instance of those JavaW-sessions.

If you need any more information or clarification, please let me know.
 

ewilson

Member
@Robertics78 ,

There's nothing inherent to javaw.exe that would keep you from using it to run the same JAR multiple times. The question really comes down to the JAR and what the actual Java application in it does. If it implements some sort of single process checking then that's a design decision made by the developer of that application.

Best advice is to simply try it.

Cheers,
Eric
 

Robertics78

New Member
@Robertics78 ,

There's nothing inherent to javaw.exe that would keep you from using it to run the same JAR multiple times. The question really comes down to the JAR and what the actual Java application in it does. If it implements some sort of single process checking then that's a design decision made by the developer of that application.

Best advice is to simply try it.

Cheers,
Eric
Hi Eric,

Thanks for your reply.
It's indeed possible to start multiple instances through BP: The problem comes with BP then being unable to properly target each individual instance.
The JAR itself is an app which retrieves data from a database - since we'll be retrieving data from about 200 databases, we thought it might make sense to do the retrieval part with multiple instances running at once (FYI, it's running on a multi-bot architecture without any problems, but we're trying to not use too many bots for this particular process).

When executing the JAR file, the name of the title bar is the same for all windows of each instance, and since it's running through Java, I also can't address the executable.

Does anyone know how Excel does it? Excel seems to be able to start up multiple instances, and address each individually: Is this because the title bar of each instances is different at startup and as such BP is able to target each? (even though this title bar/name changes)

Or is there a particular trick to link to each individual instance of an app, once the title bar is the same for all of them?
 

ewilson

Member
@Robertics78 ,

When you talk about Excel are you referring to how the MS Excel VBO can support multiple instances of Excel? If so, you'll want to take a look at the Create Instance action of the VBO and the GetHandle function in the Global Code. What you'll see is that the action creates a GUID and ties it to the new Excel instance each time it creates one, and the GetHandle function tracks the instance in a key/value map. This internal map is used for keeping track of the specific instances.

Could you apply this concept to your Java problem? Possibly. If, instead of having Application Modeller kick of the instance you could create a Launch action on the VBO that starts a new instance of the Java application and then associates a GUID, or even the process ID, with it. The VBO would then have to keep an internal dictionary (key/value map) of the that key value along with the object instance of the Java process. Each time you want to do something with a UI, you have pass in the key for specific instance and then attach to the correct one first. Does that make sense?

Cheers,
Eric
 
Top