• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

try and catch block

 
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 ]
 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try command.com instead of cmd.exe:

https://coderanch.com/t/367082/java/java/Executing-Dos-based-command
 
Sheriff
Posts: 9103
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: 9103
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.
 
Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic