Open default browser from a java application

How is possible to make a java application that open an html file in the default browser ?
Thankyou
[email protected]

You can do that by running the command "start <url>", for example using Runtime.exec().
Runtime.getRuntime().exec("start http://java.sun.com");Jesper

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.

  • Opening default Browser from embedded Flash

    The Situation is this:
    I have a running flash application myapp.swf (Actionscript
    2), which runs on a server and requires a parameter (
    http://myserver.com/myapp.swf?myparam=value).
    I now want to create an AIR Wrapper for this application. So
    I embed the above URL in a html-based AIR Project using the embed
    tag. When I launch my new AIR Project the application is displayed,
    but when I click on a link within the flash application a new AIR
    window opens, displaying the respective Webpage.
    But it should instead open a new tab or window in the default
    Browser of the respective operating system.
    I have tried the following without success:
    - Attempt to create a flash-based AIR Application. The
    application did not work properly since the swf file is on a server
    and not within the AIR Appplication. If I download the swf-file and
    put it in this directory I can't pass it the required parameter
    - Trying to open a default Browser window like this:
    http://snipplr.com/view/4442/adobe-air-open-new-url-with-sandbox-bridge.
    I belive this only works with a flash-based AIR Application too
    The best solution for me would be, if I could solve the
    problem without having to alter the flash part. But, if neccessary
    changing the flash part would also be an option.
    I really would appreciate any comments / suggestions on this
    matter

    I should probably add, that I am not a very experienced AIR
    Developer.
    quote:
    So lets get this straight, you now have the content
    embedded/loaded within a HTMLLOADER, right?
    Probably not... I have a Html based project. Meaning that I
    refer to an initial html file from my application.xml. In this html
    File I embed the mentioned flash application using the following
    line:
    < embed height="100%" width="100%" src="
    http://myserver.com/myapp.swf?myparam=value"
    />
    Could I use HTMLLoader in a HTML-based AIR app?
    quote:
    And when the AIR APPLICATION is launched, you would want the
    links that are embedded within the HTMLLOADER to open up in a
    browser?
    This is correct, but it should open up the default Browser
    like IE or Firefox but not a new AIR window.
    quote:
    Are you using: navigateToURL(new URLRequest("
    http://" + url), "_blank");
    I am not using navigateToURL since the flash application I am
    working with "does not know" that it is wrapped by an AIR
    application. Therefore, it opens new URLs the way it is normally
    done in a flash stand-alone application.
    As I see it AIR recognises that a link is being called and
    opens a new, AIR window instance.
    I have seen the article about Windows Vista before, but I
    would think that it is not directly related to my problem, since I
    do not have to problem whether links are being opened in, for
    example, Firefox or Internet Explorer but links are opened in a
    build-in AIR Window.
    I hope shed some light on the problem I am having...

  • How to open JSP session from a java application or an applet?

    Hi,
    My problem is a bit challenging (at least for me) and its not about JSP but it is about a web application..
    I couldnt find a better place to post this question I am sorry if this is not the right place to post it..
    I need to enable users log into my website by checking username and password and reading and checking the data from a usb device located in client computer.
    I can read from the device thorough JNI using the third party DLL file for the device... I have no problem with that..
    Since I need to make native calls I am planning to develop a java application so I let the users open the application using web start.. Once my application is running on client side after reading the device and getting login password information (assuming login information correct), How can I open a web session for the that spesific user and a web browser and let the user browse the web site on his/her own session?
    I would appreciate any guidance..
    Thanks..

    add the values in the header using...
    response.addHeader("userNmae","XXXX");use it in all ur pages like say..
    if(!request.getHeader("userName")!=null && request.getParameter("userName").equlas(""))
    String username=request.getParameter("userName");
    }

  • Opening a browser from a swing application

    hi,
    I want to open a browser (with specific URL) from my application, on the actionEvent of certain Button. Is it possible ? If any body is aware of it plz help me.
    Thanks
    Atul

    Try out the following site,
    http://www.stanford.edu/~ejalbert/software/BrowserLauncher/
    rgds
    Ravi

  • Launching a Browser from a Java Application

    I want to open an HTML page in the "default" browser. I know how to run commands so I could open IE or Netscape but I want to open a browser without having to know what browser they have installed. It would be nice if there is something that isn't platform dependent. Is this possible?

    It would be nice if there is something that isn't platform dependent. So you've seen the java tip
    http://www.javaworld.com/javaworld/javatips/jw-javatip66.html
    I don't think it's that easy to do what you want so that it is portable... sad that the current API doesn't have great support for programs written in other languages than Java.

  • 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);

  • 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).

  • Opening an URL from a JAVA application

    hi,
    iam new to Java.
    Currently iam designing a simle GUI which takes input(URL) from user in a test field and has a button.Upon clicking button i want to open the webPage specified by that URL in a default webBrowser.
    How can i do that(opening webPage)?
    advanced thanks for your help.
    vd.rach

    getting an error on that line as follows: "unreported
    exception; must be caught or declared to be thrown".exec() throws IOException so catch it.
    try {
    Runtime.getRuntime.exec(...);
    catch(IOException e) {
    System.err("Cannot launch the browser: " + e.getMessage());
    }On the side note: I found javaworld's [url http://www.javaworld.com/javatips/jw-javatip66_p.html]solution most useful in serving this purpose in a project, even though its a little bit platform specific.

  • Closing browser from a java application

    I have an applet having a button Save on it. I am calling a javascript function of closing the browser. But if i click it, a built in message comes to confirm the closing of browser having two opitons Yes and No. Is there any possibility that the browser closes without showing this message?

    May this is the wrong forum to post this message. However you could avoid that close-dialog by setting an opener
      function closeWindow() {
        window.opener="x";
        window.close();
      }So you can fake an self-opened window.
    The behaviour depends on used browser. So this should work for IE and Opera but not for Netscape...
    br
    karl

  • Control browser properties from a java application while launching a browse

    How to control the properties of a browser when it is launched from a java application?
    I am using the command " Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+url); " to launch the browser. The syntax of "exec" command is "public Process exec(String command,String[] envp) throws IOException". I would like to know whether we can give the arguments in this command to control the browser properties.
    If you know any other option by which we can open a URL in a controlled browser, please share it.
    Thanks in advance :).
    Surekha_Venugopal

    Hi All,
    I have found a solution to control browser parameters from Java applications.
    1. Create an intermediate HTML file at runtime which contains Javascript to launch a browser. Pass the parameters like the URL and browser control parameters to the Javascript of this HTML file.
    2. Open this HTML file and invoke the javascript while loading the file. Javascript will launch the required URL in a controlled browser.
    3. Close the intermediate HTML file.
    Limitation:
    1. There will be a flickering of windows.
    2. Applets will have permission issues with the above solution. For applets a better solution is JSobject. No need of an intermediate file here.
    Hope this will be useful for someone. :-)
    Cheers,
    Surekha_Venugopal

  • Easiest way to launch a link to the default browser from java?

    Is there an easy way to launch a link in the default browser from java? Ideally I would have a graphic in a cell that when clicked on would open a new window/tab in the default browser. This would be done in SWT, but it might be similar to swing, awt, etc. Any ideas?

    If you are using Java 1.5 or earlier, I found the browser launch code found here to work fairly well: http://www.centerkey.com/java/browser

  • 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 do I save and import my bookmarks from another hard drive? When I try to open the installed Firefox on the old drive, it (obviously) opens a browser from the new main drive, free of bookmarks. Is there a way I can save the bookmarks on the old drive w

    How do I save and import my bookmarks from another hard drive? When I try to open the installed Firefox on the old drive, it (obviously) opens a browser from the new main drive, free of bookmarks. Is there a way I can save the bookmarks on the old drive without opening a browser?
    The guts of my computer were rearranged and I got a new main hard drive. My old one is still in there and I can get stuff from it, but when I go to the Mozilla folder on the old one, I can't figure out if there's anything I can do to get all my bookmarks from that drive to my new one, where Firefox is newly installed.

    If you open Firefox then Firefox will always use the default profile folder as found via profiles.ini on your system drive.
    You either need to import the file in your current default profile or copy the file to your current profile folder while Firefox is closed.
    Firefox 3 stores the bookmarks and the browser history in [http://kb.mozillazine.org/places.sqlite places.sqlite] and no longer creates an HTML backup by default.
    There are also (five) JSON backups in the bookmarkbackups folder within the Firefox profile folder.
    You can either copy the file places.sqlite to your [http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Folder] or import the most recent JSON backup from the bookmarkbackups folder of that old profile.
    See:
    http://kb.mozillazine.org/Backing_up_and_restoring_bookmarks_-_Firefox
    http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox
    See http://kb.mozillazine.org/Profile_folder_-_Firefox
    "Application Data" in XP/Win2K and "AppData" in Vista/Windows 7 are hidden folders.
    See http://kb.mozillazine.org/Show_hidden_files_and_folders
    Go to: Control Panel > Folder Options > "View" tab > under "Hidden files and folders", select "Show hidden files and folders".
    You may want to un-check the box "Hide extensions for known file types" to see the file extensions of all files.

Maybe you are looking for

  • No video on iPhone 3G

    My video export from quicktime in set up to iPhone. I see this video on itunes, and sync to iPhone. But video no appeared in iPod app. Itunes show me is it, on iPhone. I Restart, restore and upgrade and no work. I try another iPhone 2 gen. and work,

  • How to hide "Create Requisition Request" link in MSS

    Hi All How to hide "Create Requisition Request" link which is in Recruiting services in MSS? Rgrds Sri

  • Lenovo C series 200

    I recently upgrade my hard drive and installed Windows 7 professional, I noticed that on power up the Hard disc drive indicator and the Wireless LAN card indicator extinguish but the LCD ON/OFF indicator remains on together with a blank screen. When

  • Why does my volumne button keep going off?

    Why does my volumne button keep going off?

  • Iphoto Library in use by another application or unreadable msg???

    I keep getting the above message, I can't rebuild or repair library, have had to create a new library, tried Iphoto Library Manager, have located photos and importing all 40000+ pics however i seem to have lost albums and events which is a real nuisa