| Author |
try and catch block
|
Jherald Lacambra
Ranch Hand
Joined: Feb 02, 2005
Posts: 129
|
|
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 ]
|
jherald
|
 |
Stephen Huey
Ranch Hand
Joined: Jul 15, 2003
Posts: 618
|
|
Try command.com instead of cmd.exe: http://www.coderanch.com/t/367082/java/java/Executing-Dos-based-command
|
 |
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
|
|
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 ]
|
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
|
 |
Jherald Lacambra
Ranch Hand
Joined: Feb 02, 2005
Posts: 129
|
|
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
Joined: Jul 22, 2000
Posts: 9033
|
|
|
Note that both Stephen Huey and I said to use command.com rather than command.exe
|
 |
Jherald Lacambra
Ranch Hand
Joined: Feb 02, 2005
Posts: 129
|
|
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.
|
 |
 |
|
|
subject: try and catch block
|
|
|