"Hrvoje Somun" <hr****************@zg.tel.hr> wrote in message
news:br**********@sunce.iskon.hr...
How can i call some other program from java application?
let say i want to call iexplorer('iexplore' from command line)...
thnx
You may care to try the code below.
I hope this helps.
Anthony Borla
// ---------------------------------------------
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
public class LaunchIE
{
public static void main(String[] args)
{
if (args.length < 1)
{
System.err.println("Usage: java LaunchIE filename");
System.exit(1);
}
try
{
viewFile(new File(args[0]));
}
catch (FileNotFoundException e)
{
System.err.println("File could not be located, or does not exist");
}
catch (IOException e)
{
System.err.println("File could not be opened");
}
}
// Win32-specific Code
public static void viewFile(File file)
throws FileNotFoundException, IOException
{
if (!file.isFile())
throw new FileNotFoundException();
StringBuffer cmd =
new StringBuffer("rundll32 SHELL32.DLL,ShellExec_RunDLL ");
cmd.append(file.getAbsolutePath());
Runtime.getRuntime().exec(cmd.toString());
}
}
// --------------------------------------------