Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to open internet explorer with desired site address..reply urgently

 
p sata
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


import java.awt.*;
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.net.URL;
public class Try extends JPanel implements ActionListener
{
JButton jb1;
public static void main(String[] args)
{
JFrame frame= new JFrame("Pinal");
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.getContentPane().add(new Try(), BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
}
Try()
{
jb1 = new JButton("Click Me");
jb1.addActionListener(this);
add(jb1);
}


public void actionPerformed(ActionEvent e)
{

Runtime r = Runtime.getRuntime();
Process p = null;
try
{
//URL hp = new URL("http://www.yahoo.com");
p = r.exec("C:/Program Files/Internet Explorer/iexplore.exe");

}
catch (Exception ex)
{
System.out.println("Hello " + ex);
}
}

}



With above programm my explorer is opning... but not with url i specified...
This all requirment is for standalone application....
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Well just chk the path u r giving ..

it works I tried just now..
Regds
Gautham Kasinath
 
p sata
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thanx things are working....

public void actionPerformed(ActionEvent e)
{

Runtime r = Runtime.getRuntime();
Process p = null;
try
{
String abc = "http://www.yahoo.com";
String ab = "C:/Program Files/Internet Explorer/iexplore.exe " + abc;
p = r.exec(ab);

}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic