Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);

}
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic