How can I launch a web browser from my Java application?

I've reed about this at Question of the Week (http://developer.java.sun.com/developer/qow/archive/15/index.html). It doesn't work for me. I'm running win2000 and trying:
try {
Runtime.getRuntime().exec("start iexplore http://java.sun.com");
} catch (Exception e) {
System.out.println( e.getMessage() );
I get:
CreateProcess: start iexplore http://java.sun.com error=2
What's wrong?

This function will launch the default browser under Windows.
public static void displayURL(String url) throws IOException   {
    String cmd = null;
    Process p;
    try  {
        String os = System.getProperty("os.name");     
        if (os != null && os.startsWith("Windows")) {
            if (os.startsWith("Windows 9") || os.startsWith("Windows Me"))  // Windows 9x/Me
                cmd = "start " + url;
            else // Windows NT/2000/XP
                cmd = "cmd /c start " + url;
            p = Runtime.getRuntime().exec(cmd);     
    catch(IOException x)        {
        // couldn't exec browser
        System.err.println("Could not invoke browser, command=" + cmd);

Similar Messages

  • Launch a default web browser from my java application

    Hello,
    I have been trying to launch my default web browser from my java application, but am unable do it. Right now, I am using ---- "Runtime.getRuntime().exec("cmd /c start <url>"); to launch my webbrowser. It launches the browser but displays the command prompt for a second or so, and then replaces my already existing page with the new url.
    Is there any way for me to launch the url in a completely new browser each and every time. And I don't want the command prompt to show up for a sec. Please help...!
    Thanks in advance.
    -BusyBusyBee

    If by any chance your application is an Applet, you can use this to open a new browser window:
    getAppletContext().showDocument(new URL(theUrl), "_blank");
    But, you probably would have specified if that were the case. Oh well. Hope it helps someone!
    -sheepy.

  • Attempting to launch a help browser from a java application

    I am currently investigating being able to view help html files through launching a browser from my Java application. I have come across the java.lang.Runtime and java.lang.Process classes which allow me to launch a browser like Netscape or Explorer and bring up a html file to view.
    What I want to do is launch the browser and bring up an html index file as well as the required html help file every time a user would like to use the help for my application.
    Is this possible using the other exec commands. If so, how? Is there somewhere I can find a user guide for Netscape and Explorer commands in order to send additional commands to the browser in order to do this.
    Thanks.

    Good news is it must be possible because VisualAge does it but I don't know how.

  • How can i call a jasper report from a java Application

    Hi,
    i am chiranjit , currently i working in a web based ERP project, in this project as a report building tool we are using JasperReport wih eclipse plugin . in eclipse report's are generating very well but i am unable to call that report from a java application because i have no idea about the How to call a Jasper Report from a Java Application . so please send me the necessary class names, jar files names and programe code as early as possible.
    Chiranjit

    Ahh, kind of a duplicate thread:
    http://forums.java.sun.com/thread.jspa?threadID=631642
    @OP. You could have clarified your original post and the relationship of your question to java. You did not need a new thread.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How can i call a VB6 project from my java application using JNI

    hi
    can anyone tell me the procedure of calling a VB6 project from any java application using JNI
    if anyone does know then tell me the detail procedure of doing that. I know that i have to create a dll of that VB6 project then to call it from the java application.
    if anyone know that procedure of creating dll file of an existing VB6 project please reply
    please if anyone know then let me know

    Ahh, kind of a duplicate thread:
    http://forums.java.sun.com/thread.jspa?threadID=631642
    @OP. You could have clarified your original post and the relationship of your question to java. You did not need a new thread.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How can access MS Outlook Calender information  from my Java application.

    People schedule meeting with some data on regular basis.
    I need to access the Exchange server from my Java application and get the meeting dates along with other data pertaining to meeting.

    I had the same problem, and I dont think (as far as my knowledge goes) there is any freeware that will enable Java to access Exchange server. But there are some commercial products that are available.
    Chk this link as an example: http://www.compoze.com/products_hme_desc.html
    good luck in the research
    -kms

  • Open URL in Web Browser from a Java Application

    Hi,
    I have an HTML document that I want to load in a browser window by clicking on a button in my java GUI application.
    Any suggestions?
    Thanks.

    You can use the Process class to start the web browser with the proper command line arguments (depends on the web browser though). Or on windows, you can have your program create a batch file with the code start url (where [url] is your url), and this will open the default web browser when run (again you must run it with a Process).

  • How can i delete genio web browser?

    how can I delete Genio web browser from my mac pro?

    Disable the extension from any web browsers you use.
    Go to Macintosh HD -> Library -> LaunchAgents
    Delete anything that starts with com.genio
    Repeat for Macintosh HD -> Library -> LaunchDaemons
    Repeat for username -> Library -> LaunchAgents
    Repeat for username -> Library -> LaunchDaemons
    Restart.
    That should do it. Don't download any programs to uninstall it, as they're likely to be additional malware-type programs.
    BTW I think it's spelled Genieo, so check for that too.
    I knew I had seen this somewhere - more detailed instsructions here:
    http://www.thesafemac.com/arg-genieo/

  • How can i restore safari web browser on my mac book pro?

    how can i restore safari web browser on my mac book pro?

    Backup your system/data then start up holding down Command + R and select to reinstall your OS X. You have not mentioned which OS X you are using. If you have somehow deleted the Safari App for some reason, you need to reinstall the OS X to reinstall Safari properly. You should not lose any data, but if you do, then that is what the backup is for.
    Pete

  • How do i Hyperlink to a web page from a java application?

    How do i Hyperlink to a web page from a java application using internet explorer as my default web browser?

    It's very simple.You can start any Application with the class Runtime. The command is an array consisting of the path of .exe and the file to be open.
    String [] cmd={path of IE+Filename.exe,"URL of your website"}
    try
    Runtime.getRuntime().exec(cmd);
    catch (Exception e)
    System.err.println(e.toString());
    }

  • How can i build RPMs file for my own Java Application?

    How can i build RPMs file for my own Java Application?....I have my own directory that contains all Java Source files and some files that my Application required....I want to build RPMs file like a install File to Linux System, Now my OS is Linux Fedora core 1.....How can i do this?

    I think that in order to create a RPM, you'd need to
    use some C.Nope - the RPM is all about packaging and the "magic" x.spec file. You can have anything you want in the RPM, but you have to use RPM tools to build the .rpm file. One of the features is that you can also indicate (via "install" scripts) modifications to other files or the filesystem to support the installation of whatever's in the RPM.

  • How to launch a web browser from a MAC java app

    I know, this topic has been brought up over, and over, however I couldn't find info regarding MAC environments. I don't have any former experience with MAC, but now I'm getting desperate for a solution. I need to be able to pop up the default browser showing a certain URL on MAC/OS from a java application. Any clue would be appreciated.
    Thanks a lot,
    michael berdan

    I wrote libraies that will do this:
    http://ostermiller.org/utils/Browser.html
    I also keep a list of other resources to help you out:
    http://dmoz.org/Bookmarks/D/deadsea/Java_Help/Web_Browser/
    Stephen

  • Calling a web service from a Java application

    Does anyone have sample code showing how to call a web service over from a Java application? I'm deploy to HP-UX and seeking out the most standard and reliable approach.
    Thank you in advance.

    Keith,
    Download JWSDP 1.2, look at the tutorial for JAXRPC, especially
    the client portion.

  • How to make use of Windows authentication from my Java application

    I have a Java application, Instead I design one more login page for my application, I want to make use of Windows Authentication.
    How should I use that windows authentication in my java application
    can any help me in suggesting a solution

    How will they be able to access your application if they aren't users of the system?

  • How can I launch an external app from a keynote presentation?

    I'm trying to launch a Prezi presentation ("Prezi.app") from a keynote presentation, but don't know how to do it.
    Links in keynote can only refer to websites or slides within the presentation, but not to start another App, like in - I hate to say it - Powerpoint.
    Any ideas?
    Thanks
    Juergen

    Keynote is specifically prevented from opening applications.
    In Keynote 09 (the previous version), hyperlinks can:
    Jump to a slide in the same presentation
    Open a webpage in the computer’s default web browser
    Open another Keynote document
    Open an email message
    Exit the slideshow
    in Keynote 6 (the latest version) hyperlinks can:
    Jump to a Slide in the same presentation
    Web page
    Mail opens a pre-addressed email message
    Exit the presentation

Maybe you are looking for

  • How to copy/delete file

    hi, i need to come out a program, which can copy/delete file from unix directory A to directory B, on the application server. does any one have any idea how am i going to code the abap program for this? thanks

  • Session state and browser cache - Back button problem

    Hi all, I have a problem (and unless I'm missing something I think we all do) with session state and use of the browser's Back button. I really hope I'm just being dumb... Background scenario: Page P has a sidebar list allowing the user to select wha

  • Exports from Keynote to Flash doesn't work

    I am trying to create an automatic slide show and export it as an .swf (or anything) to run on a web site and it doesn't work. For documentation of my tests go to: http://www.equalivote.com/abKeynoteExportTESTS.pdf

  • EVGA 285 GTX and Apple's 30- LED release

    I just have a question what's taking so long for Apple to release a 30 inch LED display, Currently SamSung XL30 30" Inch goes for $2600, I would be gladly to pay that price because i've been waiting for Apple to bring out a LED 30 inch for 1 year and

  • Inderict Spend Analysis

    Hi, I need Lot of Information about Inderict Spend Analysis, what data, Extractstructures etc.. can be used from R/3,what oject , Inforscources, and Datatargets can be used in BW. Thanks and points will be awarded. Anil