• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Runtime.getRuntime().exec in a servlet

 
anuragbhalla
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am trying to use the method Runtime.getRuntime().exec in a servlet.But there seems to be a path problem
as it is giving IO exception.I have given path related to the servlet.What mistake am I doing ??

Thanx & Regards
Anurag Bhalla
Project Trainee
Usha Martin Infotech Ltd.
63,Udyog Vihar phase- IV
Gurgaon, Haryana
Ph. No - 6398071-78 Ext - 466
 
Sandeep Jain
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Even I have made use of Runtime.exec() method and it works fine. Can u put ur code here, with the path where u r putting ur file as it becomes easy to debug or trace the error.

------------------
Sandeep Jain
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"anuragbhalla",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.
Thanks.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your problem is probably because you are expecting the "current directory" to be set to something in particular. Servlet containers are free to set the "current directory" to whatever they linke, so you should always either use an absolute path for all executables and files you access from a servlet, or implement some way of deciding where to look (servletContext.getRealPath(), an init parameter or whatever).
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Frank
The problem was that I was not giving absolute path.

------------------
Thanx & Regards
Anurag Bhalla
Project Trainee
Usha Martin Infotech Ltd.
63,Udyog Vihar phase- IV
Gurgaon, Haryana
India
Ph. No - 6398071-78 Ext - 466
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for choosing a new name, we do apprectate it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic