• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Runtime Class method exec()

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi every one .
I want to execute "java.exe" from java Programe
Code ("but not working") :
Runtime rt = Runtime.getRuntime();
rt.exec("c:\\jdk1.2.2\\bin\\java.exe");

what's the problem in this ?
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Exec throws an IOException, it is necessary to use a try - catch :

Hope it solves your problem
Bye
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vishwas bhatt:
Code ("but not working") :
Runtime rt = Runtime.getRuntime();
rt.exec("c:\\jdk1.2.2\\bin\\java.exe");


If your problem centers around a new console window not opening itself for you, this will work on WinXP (and I think one or two flavors of NT - but I don't think all Windows operating systems):
rt.exec("cmd /c start c:\\jdk1.2.2\\bin\\java.exe");
Good Luck.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note: Of course, you'd have to provide "java.exe" with its required argument(s) - otherwise the new console window will just open, run "java.exe" which displays its simple help information, and then the console window will close as the program ("java.exe") has finished executing.
Good Luck.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic