Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Launching Internet Explorer from a java program  RSS feed

 
Cristian Herling
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am trying to launch Internet Explorer from a java program.
My code is the following:
try
{
Process p = Runtime.getRuntime().exec("iexplore www.hotmail.com");
try
{
p.waitFor();
}
catch( InterruptedException ie )
{
System.out.println("InterruptedException " + ie.getMessage());
}
InputStream err = p.getErrorStream();
int ctr = 0;
if ( (ctr = err.available()) > 0 )
{
byte[] buf = new byte[ctr];
System.out.println("Process failed with error:\n" + new String(buf, 0, ctr));
}
}
catch(IOException ioe)
{
System.out.println("InterruptedException " + ioe.getMessage());
}
When trying to execute this code an interrupted exception is thrown:
'InterruptedException CreateProcess: iexplore www.hotmail.com error=2'
Does anyone know what the error code means and how I could launch internet explorer?
Thanks a lot,
Cristian.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cristian,
Perhaps this will help you (assuming you haven't already seen it)
http://sourceforge.net/projects/browserlauncher/
Hope it helps.
Good Luck,
Avi.
 
Cristian Herling
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot!
Interesting class, however I managed to launch the browser with a
Process p = Runtime.getRuntime().exec("cmd.exe /c start iexplore www.hotmail.com");
Thanks anyway,
Cristian.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!