• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running a .exe file from a Java Servlet.

 
Arijit De
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic