File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DOS Window

 
Mathew Kuruvilla
Ranch Hand
Posts: 141
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I launch a dos window and execute a batch file from the actionPerformed method of an ActionListener?
 
Ulas Ergin
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you might want to investigate Runtime.exec
 
Mathew Kuruvilla
Ranch Hand
Posts: 141
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic