Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

try and catch block

 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i run this block from platforms lower than windows 2000

b1.addActionListener(new ActionListener(){
public void actionPerformed( ActionEvent evt){
txt.setText("Quotation Processing");
Process cmd;
Runtime launch = Runtime.getRuntime();
try{
cmd = launch.exec(new String[] {"cmd.exe", "/c", "chapter1.chm"});
} catch (Exception e) {
System.out.println(e);
cmd = null;
}
};
});
[ February 02, 2005: Message edited by: Jherald Lacambra ]
 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try command.com instead of cmd.exe:

http://www.coderanch.com/t/367082/java/java/Executing-Dos-based-command
 
Marilyn de Queiroz
Sheriff
Posts: 9064
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jherald Lacambra:


You can use "command.com", but you cannot use filenames bigger than 8.3
[ February 02, 2005: Message edited by: Marilyn de Queiroz ]
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ihave tried this:

b1.addActionListener(new ActionListener(){
public void actionPerformed( ActionEvent evt){
txt.setText("Quotation Processing");
Process cmd;
Runtime launch = Runtime.getRuntime();
try{
cmd = launch.exec(new String[] {"cmd.exe", "/c", "chapter1.chm"});
cmd = launch.exec(new String[] {"command.exe", "/c", "chapter1.chm"});
} catch (Exception e) {
System.out.println(e);
cmd = null;
}
};
});

The program is running but there is an error
java.io.IOException: CreateProcess: command.exe /c chapter1.chm error=2
 
Marilyn de Queiroz
Sheriff
Posts: 9064
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that both Stephen Huey and I said to use command.com rather than command.exe
 
Jherald Lacambra
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried this one

b1.addActionListener(new ActionListener(){
public void actionPerformed( ActionEvent evt){
txt.setText("Quotation Processing");
Process cmd;
Runtime launch = Runtime.getRuntime();
try{
cmd = launch.exec(new String[] {"command.com", "/c", "chapter1.chm"});
} catch (Exception e) {
System.out.println(e);
cmd = null;
}
};
});

but there is a popup:

C:\winnt\system32\command.com
c:\winnt\system32\AUTOEXEC.NT. The sytem file is not suitable for running MS-DOS and Microsoft applications.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic