This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Problems with Runtime.getRuntime().exec() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problems with Runtime.getRuntime().exec()" Watch "Problems with Runtime.getRuntime().exec()" New topic
Author

Problems with Runtime.getRuntime().exec()

Aaron Robinson
Ranch Hand

Joined: May 15, 2000
Posts: 46
I'm having problem getting this method to run executables on NT workstation. Is anyone aware of any problems with using this method? I have tried calling it from a servlet and a session bean eith the following code but neither appear to work.
Runtime.getRuntime().exec("c:\\windows\\notepad");
Also, this code will need to be deployed to Solaris. what is the platform independent way of calling an executable, in particular how do you specify the root in an independent way?

SCJP 1.0,1.1,2 SCJA 2
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12756
    
    5
I believe your path has to include the complete file name which in this case in Notepad.exe
In order to run under other operating systems etc. you are going to have to configure that string at runtime - or have all the possible configurations as constants and select at runtime depending on the operating system.
Look into the File class for opsys independent manipulation of directories, etc.
Bill
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi,
Actually the problem here you had given the wrong path in WindowsNT workstation or server the Notepad Application will be in c:\\winnt directory.
Regards,
venkat

Originally posted by Aaron Robinson:
I'm having problem getting this method to run executables on NT workstation. Is anyone aware of any problems with using this method? I have tried calling it from a servlet and a session bean eith the following code but neither appear to work.
Runtime.getRuntime().exec("c:\\windows\\notepad");
Also, this code will need to be deployed to Solaris. what is the platform independent way of calling an executable, in particular how do you specify the root in an independent way?

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problems with Runtime.getRuntime().exec()
 
Similar Threads
Problems with Runtime.getRuntime().exec()
Help? Java Command Shell
how to call .exe file by clicking the JButton..?
Problems with Runtime.getRuntime().exec()
linux commands from JSP page