I am maintaining a Java EE 5 application where a .NET .exe file is being run in regular intervals from a thead spawned from a Java Servlet's init( ) method.
Is this acceptable practice? Some red flags jump out
(1) For starters one should not normally tamper with a servlet's init( ) or service( ) methods.
(2) Using a Runtime class instance to run a .exe looks hacky to me.
Am I correct in my understanding? If so what alternatives on how to run .exe file is availaible. Please let me know. Web services comes to mind, but there is nobody at the .net end to create a endpoint.
Invoking non-Java code directly from Java code is not an ideal way to do things, although sometimes one has no choice.
You usually wouldn't do it from a servlet's init() method. Especially if it's run periodically. For that kind of stuff, the servelet init() method (or a contextListener) should either spawn a thread that uses a Timer to wake up, or uses a scheduler system such as Quartz to run the task periodically.
Runtime.exec() is "hacky". but if you are crossing language barriers, it's pretty much either that or connect to some sort of socket server that runs the target logic, and from what you said, the .Net folks are not up to that. CORBA was originally designed for stuff like that, but CORBA has fallen out of favor.
An IDE is no substitute for an Intelligent Developer.
Acetylsalicylic acid is aspirin. This could be handy too:
the new thread boost feature brings a LOT of attention to your favorite threads