• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DOS Window

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I launch a dos window and execute a batch file from the actionPerformed method of an ActionListener?
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you might want to investigate Runtime.exec
 
Mathew Kuruvilla
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Runtime.exec worked but the way that I did it for DOS and UNIX was different.
Runtime r = Runtime.getRuntime();
if (System.getProperty("os.name").startsWith("Windows"))
sb.append("cmd /C start ").append(instaldir).append("\\MAT\\Kuruvi\\lla\\bin\\runSimulator.bat -p ").append(port);
else
sb.append("xterm -e ksh ").append(instaldir).append("/MAT/Kuruvi/lla/bin/runSimulator.sh -p ").append(port);

r.exec(sb.toString());

The ksh script for unix did not begin with a #! (hashbang) so I had to begin the command with 'ksh'. If the script had had a hashbang at the beginning, maybe I could have run the script straight away.
 
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic