• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems with Runtime.getRuntime().exec()

 
Aaron Robinson
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic