aspose file tools*
The moose likes Beginning Java and the fly likes try and catch block Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "try and catch block" Watch "try and catch block" New topic
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: 9044
    
  10
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: 9044
    
  10
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: try and catch block