aspose file tools*
The moose likes Servlets and the fly likes Runtime.getRuntime().exec  in a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Runtime.getRuntime().exec  in a servlet " Watch "Runtime.getRuntime().exec  in a servlet " New topic
Author

Runtime.getRuntime().exec in a servlet

anuragbhalla
Greenhorn

Joined: Aug 01, 2000
Posts: 16

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

Joined: Oct 25, 2000
Posts: 124
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


Try and Try Till u succeed<br /> <br />Sandeep Jain
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"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.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
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

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Jan 07, 1999
Posts: 6920
Thanks for choosing a new name, we do apprectate it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Runtime.getRuntime().exec in a servlet