Invoking system's default browser

Hi
While developing a swing application, in event handling, I would like to open a HTML file in the system's default browser like IE or netscape. Can I know how to do that?

I use the system command
rundll32 url.dll,FileProtocolHandler http://java.sun.com
but if the URL represents a known mime type then the browser doesn't launch. That's weird but you can get around it by suffixing the URL with a "#" character.

Similar Messages

  • Invoking a url in System's default browser

    Hi All!
    I have one question related to invoking an url in a browser using Runtime.getRuntime()
    I am using the command as
    command = "rundll32 url.dll,FileProtocolHandler " + url;
    Runtime.getRuntime().exec(command);
    where url = (say) http://www.java.sun.com
    This works perfectly fine for internet and intranet and intranet.
    But if my url has spaces (more than one ) it fails.
    e.g. url = "fileserver:\\Temp 12\read.html
    Now the folder is "Temp 12" having two gaps inbetween Temp and 12.
    I tried to use exec(String [] cmdArray)
    but it gives me error as "java.io.IOException: CreateProcess: www.hotmail.com "cmd /c start" error=2"
    Where cmdArray is defined as
    String[] cmdArray =
    ("rundll32 url.dll, ileProtocolHandler " + url)
    Any suggesstion or help.
    Anand

    I ran into the same problem, and found solutions at:
    http://ostermiller.org/utils/Browser.html

  • How do you invoke the default browser for Unix/OSX

    Does anyone know how to programmatically display the contents of a URL in the default browser for a Unix system? I found a javaworld article on doing this using Runtime.getRuntime().exec(cmd). The article gives the cmd string for invoking the default browser in Windows, and for invoking the Netscape browser in Unix.
    This can easily be extended to invoke any known browser executable in a known path on a Unix system; but I'd like to invoke the default browser without knowing what or where it is. I'm specifically targetting Mac/OSX, but any Unix solution is worth trying.
    Is there a Unix command for launching the default browser to display the contents of a given URL? Or is there an alternative approach, rather than invoking Runtime.exec()?
    -Mark

    After extensive google searching, I came across a partial solution. This code detects the default browser on a Mac, and provides an elegant solution for trying standard browsers in turn for other Unix systems. I tested it on WIndows XP and Mac OSX 3.9, and it detected the default browser each time. A suped up version of this tool is available as a SourceForge project. You can find it here:
    http://sourceforge.net/projects/browserlaunch2/
    Here's the simplified code:
    //  Bare Bones Browser Launch                          //
    //  Version 1.5                                        //
    //  December 10, 2005                                  //
    //  Supports: Mac OS X, GNU/Linux, Unix, Windows XP    //
    //  Example Usage:                                     //
    //     String url = "http://www.centerkey.com/";       //
    //     BareBonesBrowserLaunch.openURL(url);            //
    //  Public Domain Software -- Free to Use as You Like  //
    import java.lang.reflect.Method;
    import javax.swing.JOptionPane;
    public class BareBonesBrowserLaunch {
       private static final String errMsg = "Error attempting to launch web browser";
       public static void openURL(String url) {
          String osName = System.getProperty("os.name");
          try {
             if (osName.startsWith("Mac OS")) {
                Class fileMgr = Class.forName("com.apple.eio.FileManager");
                Method openURL = fileMgr.getDeclaredMethod("openURL",
                   new Class[] {String.class});
                openURL.invoke(null, new Object[] {url});
             else if (osName.startsWith("Windows"))
                Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
             else { //assume Unix or Linux
                String[] browsers = {
                   "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
                String browser = null;
                for (int count = 0; count < browsers.length && browser == null; count++)
                   if (Runtime.getRuntime().exec(
                         new String[] {"which", browsers[count]}).waitFor() == 0)
                      browser = browsers[count];
                if (browser == null)
                   throw new Exception("Could not find web browser");
                else
                   Runtime.getRuntime().exec(new String[] {browser, url});
          catch (Exception e) {
             JOptionPane.showMessageDialog(null, errMsg + ":\n" + e.getLocalizedMessage());
       }

  • How to check whether a default browser is opened in the operating system?

    Hi,
    I am newbie here. During my work, I faced an interesting problem. I need to:
    - check whether a default html browser is opened;
    - check whether the browser is minimized/maximized (simply, a window's state);
    - get an url address typed in the browser.
    If any of these conditions is not met, I have to open the browser in a maximized view with a desired url address. I primarily wanted to do all this in Java, but it came to my mind that I should employ many techniques/technologies and combine them appropriately to complete the functionality. But, which ones? That's the problem. I just recalled Windows API, but I'm not sure if it is of any help... On another forum, some users suggested that I should consider JNI... At this time, I only know how to open a default browser (e.g. with use of the 'browse(URI uri)' method of the 'java.awt.Desktop' class) - that's too little to be proud of. Please give me some hints, maybe links to reasonable discussions, I would greatly appreciate any suggestions how to approach the problem.

    Crosspost! [http://www.java-forums.org/advanced-java/29583-how-check-whether-default-browser-opened-operating-system.html]

  • Firefox is my default browser in my local system, i am getting junk data when i open the .html type of files as attachment but there is no issue when i open as inline

    Hi,
    could please help me of the folloing issue
    i have set up the firefox is default browser in my local system.
    issue with only .html type files not with .doc .... etc.
    my application requirement is to view the attached document if set Content-Disposition as "attachement" then open the dialog box with open or save radio options then if i select the open option data getting as junk data not the actual data.
    if set Content-Disposition as "inline"' then file open in same accessing browser with proper data.
    Note
    i am using following piece of code in my application
    response.setHeader("Content-Disposition", "attachment;filename=\""
    + fileName + "\"");
    actual my case is :
    some where in my application i copy/paste the data from ms-word
    then it saved as .html file after that when i want to see the data, then click on the attachment it opens dialog box, here i am selecting open option then it opens in my default browser "firefox" with junk data .
    please observe the following junk data,

    Hi 20fox12, this is most likely an IE problem. Firefox has no effect on any other installed applications. Unfortunately I have no idea what to do about your issue. I'd suggest a forum that is more tuned towards Windows issues.

  • Default browser isn't invoked

    Lately, when I run .JSP and .HTML file, the status says 'Ruuning, Compiled successfully.' But, the HTML(or jsp) file never runs in the browser. The files are perfectly fine, but, I have no idea what has changed. How do I reset the default browser, which is in this case, IE5.
    S

    To launch the browser, JDev "executes" a .html file, and lets the Windows file associations take care of launching the right program. So if the .html extension isn't mapped to any application in Windows, or if the mapped application executable doesn't exist, then the browser won't launch.
    You can override this behavior by going to Tools | Preferences - Web Browser/Proxy and specify a full path to the browser executable that you would like to use.

  • How to open default browser of the system using swing

    Iam doing a project in swing iam havina a problem actually if i click click a button on the top of the frame it has to open an asppage or html page in default browser. Please if any body can help me.if anybody having the code or solution please send me.

    I think, but never tried, thatexecuting a html file will automatically ask the OS to open the defaulkt browser. This is like executing a *.doc file will open Word
    o execute a file, you need to use the Process class. Usually, we do something like this
    Process p = Runtime.getRuntime().exec( your command)

  • Can not make FF my default browser...When asked I get "Your computer must be restarted to complete a previous upgrade of FF". When this is done, it's the same thing all over again...

    Can not make FF my default browser...When asked to make, I get "Your computer must be restarted to complete a previous upgrade of FF". After restart, it's the same thing all over again. I have explorer & chrome installed on my PC.
    == This happened ==
    Every time Firefox opened
    == A few monts ago.

    It is probably because you are not properly closing Firefox. Restarting your system would make sure that Firefox had terminated, but you do not have to do that.
    To properly close Firefox on Windows systems, use
    :File > Exit or "Firefox:" button > Exit
    When you get the message "Firefox is already running" it is too late, and you must force termination of Firefox through the Windows Task Manager before restarting Firefox. Windows 7 has a keyboard shortcut to save you a step "Ctrl+Shift+Esc" then on "Processes" tab, select "firefox.exe" and use the "End Process" button. More thorough would be to right-click on the "firefox.exec" and choose "End Process Tree".
    You would find firefox.exe in a Mozilla folder in your program files, but y0u would not want to delete it there, you would need to use the Control Panel which you have already identified and do it from there -- but generally you would not need to do that, and there is nothing in what you have posted to indicate that you should. But if you did do that, then don't let the install start Firefox for you as you would want to use you existing desktop icon or method of starting Firefox, and should decline having Firefox install start Firefox for you. When the install starts then invoke Firefox in your normal manner. This should eliminate problems of creating a new profile rather than using your old profile.

  • If Firefox is set as the default browser, and any application attempts to open a new window, this fails and I get the error "Firefox is already running..."

    Here is what I am running:
    Microsoft Windows 7, Service Pack 1, Fully updated to 4/10/2012
    Fresh Install of Firefox 11. No add-ons enabled as a result of troubleshooting.
    I am a user with administrator rights
    UAS is disabled.
    To begin, this has been going on Since Firefox 10 or so. A few months now.
    I am able to open Firefox. My add-ons worked (ABP, Flashblock, ABP Element Hiding Helper, IETAB2, Downthemall, Greasemonkey, 4chan extension) had no problems. Firefox is set and has been set for the last two years as my default web browser.
    However Since approximately Firefox 10 or so, maybe before that, If I have a Firefox session open, and any other application attempts to open a session in a new window, I get the Firefox is already running, but not responding error."
    I attempted to follow troubleshooting advice already posted (look for parent.lock files left behind [none present], multiple sessionstore.js files [none present], create a new user profile, attempted to clear out the "read-only" permission in windows 7, however as soon as it is cleared, the read only permission returns.)
    As a last resort, I deleted the Firefox folder, the %APPDATA%/Mozilla directory in its entirety, then utilized CCleaner to remove any and all references to Firefox in the windows registry, then did a full re-install, no extensions installed right now.
    I checked preferences and have the option "open new windows in a new tab" checked off. The problem persists regardless if this option is checked on or off. This problem persists in or out of safe mode, even with the brand new install.
    Test Cases:
    All cases:
    Firefox is selected as the default browser for windows 7
    Case 1: Open a firefox session. Utilize any other program that attempts to open a link to their website in a new browser window or new browser session. Experience "Firefox is already running" error
    Case 2: Open a firefox session. Right click on Firefox on the task bar. Select "open in new window". Experience "Firefox is already running" error
    Case 3: Open a firefox session. Select the Firefox Menu > New tab > New Window. A new window will actually open.
    This is the only method of opening a new window in the same browser session or profile that actually works on my system. Attempting to open a browser session from the task bar "open new window dialog" or opening a new window while a current window/session is running will not open firefox in a new window or a new tab in the current session. The "Firefox is already running, but is not responding" error will occur every time.

    Cor-el's suggestion resolved my problem. Apparently the MOZ_NO_REMOTE variable was set to 1 on my system variables. I never made it, and really have no idea how it got there, but deleting this variable and restarting firefox has resolved the issue. Thanks Cor-el!
    Marking case: Solved
    Solution: Verify the MOZ_NO_REMOTE variable is NOT set to 1. This can be achieved by simply deleting this variable.

  • How to change default browser to Firefox.

    Hi,
    I've upgraded our Solution Manager 7.0 to EHP1. Most of the applications that I use: sld, smd, user admin, etc. run fine in my default browser, Firefox.
    But when I use a workcenter, RCA for example, and I open a webdynpro application which runs on a separate browser window, Internet Explorer is always used. How can I change this behaviour to choose the right default browser ?
    Regards,
    Joan

    Hi Joan,
    You can set in your Firefox. Go to Tools->Options. Choose the Main tabs, then press button Check Now in system default and if your firefox not set as default browser you will be asked to change the default browser from IE to firefox. I've been using firefox as default browser to test workcenter service.
    Hope it helps.
    Rgds,
    Desty.

  • How do I set up a different default browser other than firefox?

    I would like my juno email page to come up everytime I open a new page but I can't seem to figure out how to change my default browser. Right now anytime I open a new tab the search engine is blank and it shows avg search engine. No matter what I put in the search engine after it goes to that page the search engine goes blank again. Because it keeps going blank it also keeps bringing you back up to it. So you might click on something and start writing and next thing you know you're writing in the browser again all because it disapears. It's very annoying. I want to get it off the avg search engine so I stop having these problems. I use to always have it open to my email start page so I would like to do that again or anything else if it will stop going to avg and it will keep what I ask for in the browser.

    Normally, Firefox will fill the new tab page with 9 thumbnails for your frequently visited sites. You can change that to the Juno URL if you like. Here's how:
    (1) In a new tab, type or paste '''about:config''' in the address bar and press Enter. Click the button promising to be careful.
    (2) In the search box above the list, type or paste '''newtab''' and pause while the list is filtered
    (3) Double-click the '''browser.newtab.url''' preference and enter your preferred page:
    * ''Page thumbnails (default)'' => about:newtab
    * ''Blank tab'' => about:blank
    * ''Built-in Firefox home page'' => about:home
    * ''Any other page'' => full URL to the page ''you may want to copy this from another tab first for easier pasting''
    Press Ctrl+t to open a new tab and verify that it worked. Fixed?
    * If Firefox ''refuses to save the change'', check your Windows Control Panel, Uninstall a Program, for something named Search Protect and get rid of it.
    * If Firefox ''ignores the change'', one of your extensions may be overriding it. You can review, disable, and/or remove extensions on the add-ons page:<br><br>3-bar menu button (or Tools menu) > Add-ons > ''in the left column click'' Extensions
    IMPORTANT: Your More System Details shows a user.js file in your profile. Firefox will use this file at startup to override your previous session settings. This article describes how to track down and remove the file: [[How to fix preferences that won't save]].
    Any luck?

  • After installing the safari update for windows outlook is not opening email links. I have set safari as my default browser but hyperlinks won't open a browser window - I get an error message - "This operation has been canceled due to restrictions in effec

    After installing the safari update for windows, outlook is now not opening email hyperlinks.  I have set safari to be my default browser but outlook won't open it when I click a link.  I get the following message: "This operation has been canceled due to restrictions in effect on this computer. Please contact your system administrator."  Please help.

    Hi mcclausky, you may need to manually remove a policy setting from the registry. You also should scan for malware that might have created this problem.
    This article lists scanning and cleaning tools other Firefox users have found helpful: [[Troubleshoot Firefox issues caused by malware]].
    To check your Windows registry for policy settings that might affect Firefox or other programs, I suggest consulting a Windows forum or Microsoft's forums. For example:
    * http://windowssecrets.com/forums/
    * [http://answers.microsoft.com/en-us/windows/forum/windows_8-system/this-operation-has-been-cancelled-due-to/9677848e-072d-4206-87f4-9da9284d6151 This operation has been cancelled due to restrictions in effect on this computer. Please contact your system administrator. - Microsoft Community]
    * [http://answers.microsoft.com/en-us/windows/forum/windows_xp-security/restrictions-this-operation-has-been-cancelled-due/8af1d0cd-8fbd-4223-9396-86d7497bb275 Restrictions. This operation has been cancelled due to to restrictions in effect on this computer.Please contact your system administrator. - Microsoft Community]

  • How do I setup Safari to be my default browser for Mail?

    I am using an iMac with Yosemite 10.10.2, Safari is 8.0.3, Mail is 8.2.  Somehow, awhile ago, I set up my default browser as Firefox 35.0.1, and have been satisfied with it.  Lately I have become unhappy with the way it responds to some clicks.  I would like to try Safari, though I might miss some features of Firefox. 

    Open System Preferences > General then select Safari from the Default web browser:  pop up menu.

  • How to open a URL in the default browser via CC HTML Extension?

    Hi,
    I'm trying to open a link via the default browser in a HTML Extension for Photoshop CC built with Extension Builder 3.
    With the initial example the "/indext.html" it look like this:
    <li><button class="default" id="btn_PHXS" onClick="onClickButton('PHXS')" disabled="true">Run ps code</button></li>
    and I changed the code from "/ext.js" to:
    ...function onClickButton(ppid) {    var csInterface = new CSInterface();    csInterface.openURLInDefaultBrowser('http://www.adobe.com');}...
    This is what the "/lib/CSInterface-4.0.0.js" looks like:
    * Opens a page in the default system browser.
    * @param url   The URL of the page to open. Must use HTTP or HTTPS protocol.
    * @return One of these error codes:\n
    *      <ul>\n
    *          <li>NO_ERROR - 0</li>\n
    *          <li>ERR_UNKNOWN - 1</li>\n
    *          <li>ERR_INVALID_PARAMS - 2</li>\n
    *          <li>ERR_INVALID_URL - 201</li>\n
    *      </ul>\n
    CSInterface.prototype.openURLInDefaultBrowser = function(url)
        return cep.util.openURLInDefaultBrowser(url);
    Since "util" doesn't seem to be defined  I get the message:
    Uncaught TypeError: Cannot call method 'openURLInDefaultBrowser' of undefined
    Is the something missing?
    Thx,
    frankin

    Hi Franklin,
    Apologies for the delay but I have been trying to determine why this API is not been working. I have since discovered that, although this API is documented in the JS library, the behaviour has yet to be implemented into Photoshop CC. Offline I will try to determine why this API was included in the library when it was not ready but for the meantime, if you would like to open a browser, here is a workaround:
    Instead of using:
    //(new CSInterface).openURLInDefaultBrowser("http://www.adobe.com")
    // Use the createProcess API to open a browser. The following shows a workflow in Windows to open Internet Explorer.  
    var csInterface = new CSInterface();
    var rootDir = "/";
    var isWindows = window.navigator.platform.toLowerCase().indexOf("win") > -1;
    if (isWindows) {
                        rootDir = csInterface.getSystemPath(SystemPath.COMMON_FILES).substring(0, 3);
    var processPath = "/usr/bin/open";
      if (isWindows) {
        processPath = rootDir + "Windows/explorer.exe";
    var url = "http://www.adobe.com";
    window.cep.process.createProcess(processPath, url);
    Apologies for this inconvenience but we promise to keep you informed when openURLInDefaultBrowser API is fully supported.
    Kind regards,
    Lea

  • How to change the default browser for "Search in Google" pop-up menu?

    This issue has come up for the last three OS X releases, at least, and it's still here for Lion.
    I'm in Apple Mail and select some text. I want to search on the term using Google. Right-click brings up the context menu with "Search in Google." This inevitably results in Safari opening for the search.
    Chrome is definitely set as my default browser. Clicking links in email messages brings them up in the proper browser. "Search in Google" does not. Wherever this context menu item is selected (Mail, TextEdit, etc.) it opens Safari instead of the default browser.
    As far as I'm concerned, that makes the context menu item useless, since I do not use Safari.
    Has anyone figured out a workaround?
    Has anyone in the OS X team at Apple paid attention to this issue? It is not new.

    This post helped me.
    https://code.google.com/p/chromium/issues/detail?id=147510
    Basically, the "Search in Google" extension is from Safari and it can be disabled in System Preferences.
    System Preferences -> Keyboard -> Keyboard Shortcuts -> Services -> Searching and unchecking "Search with Google"
    It worked for me and I also disabled a few other right-click options that I never use.

Maybe you are looking for

  • Use abap report program to print bar code instead of smartforms

    Do anyone know how to use abap report program to print bar code?

  • Is someone using my internet connection?

    My bills are showing more and more GB's used every month which makes me think maybe someone is using my connection? I am running mac osx 10.4 (not windows!) and have a netgear wireless router. Does anyone know of a way to check if anyone else is usin

  • No longer snooze times in mavericks calendar?

    I think I have this figured out now after several runs through these discussions and other forums, but I want to make sure I'm correct in my understanding... can someone please confirm? I used to rely heavily on ical alerts for things that didn't hav

  • Is Firefox available for Win7 64bit?

    I have Firefox 2.0 running on a Windows 7 64bit OS. I am unable to update to the latest firefox version and therefore I am unable to open some personal account web pages. How do I solve this and remain with Firefox as I don't want to go back to Inter

  • HT5656 IPv6 Delegated Prefix doesn't stay set

    Just as others have encountered after the upgrade to 7.6.3, the required field IPV6 Delegated prefix keeps getting unset.  When I click on the error pessage about a broken IPv6 tunnel and click Edit, it highlights the remote IPv4 address, which is se