4

I want to know if there is a way to open a webpage specifically in internet explorer using the java Desktop utility. My company uses both firefox and IE, but the url that needs to be open, is only compatible in IE. So, my java class needs to open that url in IE no matter what the default browser is.

Thanks for your help.

3
  • 2
    Sounds like your Java program should do a Runtime.getRuntime().exec("iexplore http://someurl.com") Commented Aug 21, 2012 at 19:19
  • Thank you paulsm4... I will try the code and see how it goes. Commented Aug 22, 2012 at 15:19
  • Cool - glad it worked :) Please "accept" Tudor's response :) Commented Aug 22, 2012 at 16:26

3 Answers 3

8

Sure:

Runtime.getRuntime().exec("iexplore.exe www.stackoverflow.com");
Sign up to request clarification or add additional context in comments.

3 Comments

@Tudor: Thanks a lot, I will give it a shot and let you know.
@AndrewThompson: Can you elaborate a bit further? I am far away from being an expert in Java. I was wondering if you can give me a short code example. Thanks for your feedback though.
"give me a short code example." 'Give me money'. No, SO is not a code factory. But make an attempt, show some effort, and I might oblige.
1

This might be late to answer the question, But still I will try to add my 2 cents. The question asked is "How to open URL in internet explorer using java Desktop" The below line of code mentioned in previous answer is correct but it will open in IE only if path is set to it. If there is not path set it will not work and throw error Runtime.getRuntime().exec("iexplore.exe www.stackoverflow.com");

To Force Java open Webpae in IE below is the line of code worked for me even though my default browser is Edge and path for IE is "not" set.

Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\iexplore.exe https://carelink.minimed.eu/");

Thanks

Comments

-1

try this:

//e.g. myURL=www.google.ch
public void openBrowser(String myURL) {

    //open default OS browser
    URI myURI;
    try {
        myURI = new URI(myURL);
        Desktop my = Desktop.getDesktop();
        if (!Desktop.isDesktopSupported()) {
            System.out.println("[WARNING] NOT SUPPORTED");
        }
        my.browse(myURI);
    } catch (URISyntaxException | IOException e1) {
        e1.printStackTrace();
    }
}

1 Comment

That doesn't seem to explain how to guarantee that the IExplorer is used. This question seems to be answered - I don't see any improvement coming with this new answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.