Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

execute java app in servlet  RSS feed

 
Eva Tang
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to execute another java application in my servlet, I did:
Runtime.getRuntime().exec("java myapp");
and then redirect to another jsp page.
the java application I'm calling should print out a line and generate an excel (.xls) file. The servlet redirect without executing the java application, any idea how I can get java application to execute in a servlet?
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While that should work, why don't you just call myApp's main method?
Suppose you have:

Then in the servlet:
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't just start a program with exec and walk away. You have to provide for consuming the standard out and standard error character streams or it will just hang - see the java.lang.Process class.
Bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!