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());
   }

Similar Messages

  • How do you set the default magnification for Acrobat.  All documents that I open enlarge to 174% and are too big.

    How do you set the default magnification for Acrobat.  All documents that I open enlarge to 174% and are too big.  I see how to change the size after the document is open by going to File/properties/initial view and saving this setting.  I want all documents to open at 100% when they are first opened.  Can I set this as a default view?

    Hey Kris,
    You might go to Edit> Preferences> Zoom
    Do this without opening any particular PDF so that it applies to the program itself and not just one document.
    Try this and then let me know.
    Regards,
    Anubha

  • How do you change the default setting for RTF documents from TextEdit to MS Word

    How do you change the default setting for RTF documents from TextEdit to MS Word, I download forms from the Canadian government and they use RTF as a standard, they are supposed to open as MS Word documents (Yes I have Office for MAC 2011) but when download the document it goes to TextEdit which messes up the form format. I can down load it right click and go "open with" MS Word but how can I get the default chnaged to save this step.

    richr604 wrote:
    Thanks I knew this, I like Safari as I want to keep everything MAC, but if I use Firefox the documents open in MS Word straight away, I was just curious if there was some setting I could change?
    In Firefox > Preferences, click the Applications tab. If RTF is there, use the pulldown menu in the Action column to pick MS Word. If RTF is not there, there are instructions here for how to add file types.

  • How to make Firefox the default browser for Hotmail

    I recently uninstalled Safari because I want to use Firefox as my default browser. Previously when I click the Mail button in Windows Live Messenger, the mac would automatically open my hotmail in Safari. Now that I have uninstalled it, when I click on the Mail button, it opens up with TextEdit. How do I make it open with Firefox?
    Any help is much appreciated.
    Thanks,
    Joe

    OK I'll post there also but I'm aware of the preferences section in Safari... thing is, when I choose to make Firefox the default browser, it resets back to Safari when I turn off the computer and turn it back on. Everytime. And it does my head in
    I heard of a program called More Internet that I heard could help slove the problem but I can't understand how to use it, nor is there any forum or any way to contact anyone who knows. It's driving me up the wall.
    So I'm hoping there's another way that someone in the world knows.

  • How do you change the default permissions for files?

    I have all my users saving (via AFP) to an Xserve RAID, I am using ACL to control who has access to certain area.
    This is fine when moving files in the finder, all ACL are respected, however when saving files from Photoshop it ignores the ACL's.
    So if user A saves a file they become the owner- which is fine, but the group and everyone permissions are read only, so when user B ammends the file they get a permission warning when they try to save, the work round I'm using is to trash the file just before you try to save- not ideal cos if the save fails you've lost the work.
    What I would like is for the default permission to be group "design" Read and Write and leave everyone as read only
    So when any designer goes to oversave a file in photoshop they can do.
    I needf to leave ACL's on as they are working well in every other situation, i.e I have certain folders set so once images have been added they cannot be deleted or renamed by certain users.
    It only seems to be Photoshop that gives us this problem, Quark files and other docs are able to be saved according to the ACL

    Hi
    There are some important distinctions and points to be made here.
    POSIX Permissions are always set for every file and folder. ACLs are optional for any file, folder or share point and work IN ADDITION to POSIX Permissions. SACLs (Service Access Control Lists) are optional for specific services such as AFP, FTP, SMB, Mail etc and are independent of files and folder as well of standard POSIX Permissions and file system ACLs. Allow access is cumulative and Deny access is first match.
    ACLs supersede but don’t necessarily override Standard UNIX permissions.
    The best way to use ACLs is to enable Access Control Lists on the desired volume, create the share point folder from within Workgroup Manager, define the Users and Groups and then drop the relevant User and/or Group into the ACL window and define access privileges from there. Don’t be tempted to use the Standard UNIX permissions in addition to ACLs as all sorts of problems can ensue.
    Privileges and access can quickly get confused and share points can be broken. Deny settings defined in ACL take precedence over all other privileges settings. Deny settings defined using Standard UNIX as well as ACLs can, in some cases, mean share points becoming inaccessible to all users even those with administrative privileges.
    Wherever possible try not to set access privileges using the Finder.
    For a much fuller explanation and a method for calculating umask values consult Gerrit de Witt’s series of articles:
    http://discussions.apple.com/thread.jspa?messageID=648307&#648307

  • How can you change the default setting for the alarm for new events?

    When I create a new Event, it will create an alarm that will activate 15 minutes before the event. I'd like to change the settings so the default setting would be that when I create a new event it will activate 1 day before the actual event. Is it possible to change this? Thanks.

    Greetings, David.
    alarm...activate 1 day before the actual event. Is it possible to change this?
    Sure.
    _Go to iCal > Preferences > General >"Add a default alarm to all new events and invitations"
    _Change the current value from 15 minutes to whatever minute value you like (1440 for 24 hours).
    _Of course this will only affect NEW events. Not those already created.
    _Close the window and your done.
    Hope that helps.

  • How do you change the default size of the print batch size for mail merge in Publisher 2010?

    I appended this question to another thread with the same topic but have not received a reply, so I'll try with a new question. Publisher 2010, when doing mail merge, will only merge and print two records at a time. How do you change the default size of
    the print batch size? This is for a 4 page document, 8 1/2 x 11, printed two sides on 11 x 17. I've tried all the suggestions that were in the other thread. The response that was marked as the answer by the moderator is incorrect and does not work. Nothing
    suggested in that thread works. A registry fix that worked for Publisher 2003 won't work because the print batch size key does not exist in the registry for Pub 2010. At least not that I can find. Printing to an XPS document doesn't work. It asks for a filename,
    prints 2 records, asks for new file name, prints 2 records, asks for new file name, and so on. The same for printing to a PDF document. Merging to a new Pub document doesn't work. When I print that job every other sheet is turned over. I.e., sheet one has
    pages 1 & 3 on top, next sheet has 3 & 4 on top, and so on. This makes it impossible to run them through the folder. The same thing happens when I print that complete merged document to XPS or PDF. I have the latest drivers installed for our printer, a Toshiba
    2500C copier/printer connected via network. What do I need to do to to change the batch size to something reasonable, like 100 records?

    It's been two weeks since I posted this question. What does it take to get an answer? I cannot believe it's being ignored, nor can I believe that someone in MS doesn't have an answer.

  • How to deactivate Photoshop CS4 as the default browser for image

    I wanted to deactivate Photoshop CS4 as the default browser for image. Now everytime when i want to open BMP(bitmap) file it always use photoshop CS4 to open the file. It takes a longer time to load the bitmap picture when using photoshop CS4 to open.
    Can anybody help!
    thank you

    Mylenium is implying just that.  There's a checkbox that reads something like [ ] Always Use This Program to Open This File Type.
    I do know that in Photoshop CS5 in Bridge there's a preference dialog that allows you to set file associations as well...  I'm not where I can test CS4 at the moment.  There may be such a dialog also in Bridge CS4.  Open Bridge, choose Edit - Preferences - File Associations if that subcategory exists, then find your file type and change the association.
    Yet a third possibility is that if you have a viewer program like IrfanView that you'd like to associate with the file type, then the viewer program likely offers a menu through which you can indicate you want that program assocated with particular file type(s).  I have instructed IrfanView to make itself the viewer for all Image types, and that works well.
    -Noel

  • How do I change the default properties for Replace(Ins)?

    Acrobat Pro X
    Comment tools: Annotations
    All tool icons EXCEPT Replace(Ins) show "Tool Default Properties" as an option when right-clicked.  When I right-click a particular replacement in the document and select "Properties," there is no option to set current as default.
    So, how do I change the default properties for this annotation tool?  I need to change the Author and the color.
    Thanks,
    Nancy

    Create customized controls for your graphs and controls and setup your favorite attributes .
    Use your custom controls instead of the canned controls.
    Do a search on UI and you will find a community that already created custom controls.
    Visualize the Solution
    CLA
    LabVIEW, LabVIEW FPGA

  • How do I change the default timezone for user calendars?

    The default timezone for new calendars is "America/New_York." How
    do I change the default timezone to my local timezone?
    To change the default timezone, perform the following steps:
    <P>
    <OL>
    <LI>Go to the bin/data/default_user_prefs.xml
    file.
    <P>
    <LI>In this file, change the values for the
    "icsTimeZone" and
    "ceSingleCalendarTZID"
    parameters. The default settings will appear something as follows:
    <P>
    <P>
    Changing these two parameters will change the timezone in the Calendar user
    interface.
    <P>
    <LI>In addition, go to the
    bin/config/ics.conf file.
    <P>
    <LI>In this file, change the value for
    calstore.default.timezoneID
    <P>
    Changing this value will enable the server to pick up the new timezones.
    </OL>
    <P>
    <B>Please note:</B> The values you enter for the above parameters must be valid
    timezones defined in the
    bin/data/timezone.ics
    file.
    <B>Related Technote:</B>
    <P>
    20000330-7: iCS 2.x: How do you change the
    default timezone in JavaScript?<BR>
    see article 4322

    Colin,
    You may substitute any text you like for the "Placeholder Text", as it is called, in Pages. Click on the existing placeholder text and type something more to your liking. Do this in as many places as your particular template of interest demands. Then, Format > Advanced > Define as Placeholder Text. Lastly, File > Save as Template.
    Now that you have defined a Custom Template to your liking, you can go to Pages Preferences and under the General tab's first section, define the new custom template as your default for each new document.
    Regards,
    Jerry

  • How do you modify the default Execute thread count in Weblogic Server 9.2?

    How do you modify the default Execute thread count in Weblogic Server 9.2?
    How can you tune the starting number of weblogic.ExecuteThread on server startup and/or set minimum number?
    Is there an option from the console?
    Please let me know.
    Thanks

    Self tuning will automatically manage the threads but however you can still control the min and max by adding the min and max values for each instance either directly adding in config.xml or through JVM settings
    1) Modifying the config.xml
    Just add the following line(s) to each server definition :
    <server>
    <name>AdminServer</name>
    <self-tuning-thread-pool-size-min>100</self-tuning-thread-pool-size-min>
    <self-tuning-thread-pool-size-max>200</self-tuning-thread-pool-size-max>
    </server>
    2) Adding some JVM parameters
    It's safer the following way :
    add the following option in your command line : -Dweblogic.threadpool.MinPoolSize=100
    Regards
    RR

  • How can I change the default setting for downloading photos from email?

    How can I change the default setting for downloading photos from emails I receive?  It shows the default as Photoshop Elements 4.0 and is not supported by this system.  That was my last computer!!
    Thanks,
    Sheila

    That has nothing to do with styles nor Pages, it is a System/Printer Driver setting.
    You can experiment to see if the Printer Settings stick with your document, but in the past this has not worked.
    Peter

  • TS2220 How do you reset the network password for Airport wireless?

    How do you reset the network password for Airport wireless?

    Use AirPort Utility...select the AirPort Express and in the menu select Base Station...Restore Default Settings...

  • How do I change the default text for when I open up pages?

    How do I change the default text for when I open up pages?

    Colin,
    You may substitute any text you like for the "Placeholder Text", as it is called, in Pages. Click on the existing placeholder text and type something more to your liking. Do this in as many places as your particular template of interest demands. Then, Format > Advanced > Define as Placeholder Text. Lastly, File > Save as Template.
    Now that you have defined a Custom Template to your liking, you can go to Pages Preferences and under the General tab's first section, define the new custom template as your default for each new document.
    Regards,
    Jerry

  • How do I modify the default account for events in iCal?

    I have several email accounts (for biz&home) and I want to use them, depending on the event, as the account from where an invitation from iCal is sent. So if a have a football game with friends, I want to use my personal account when sending an iCal event. But when I want to make a biz meeting, I want to use my work account in that invitation. How or where can I make these selections/options appear? Is it possible?
    If not, how can I set the default account for invitations in iCal? (I already have a "default" account in Mail, but iCal is not using that account for invitations).
    Any help is appreciated

    Hi salazar2,
    Been dealing with a similar issue for about 3 years now, so I know your pain. I founded a company in 2009 called Zamain that is focused on making Mac calendaring more productive. Our first product, Zamain for Mac, solves your problem as well as Apple iCal to Microsoft Outlook/Exchange incompatibilities. The current version includes the following features:
    * Sends iCal invitations that Outlook users can actually open
    * Sends invitations from any email account
    * Lets you add comments to invitation replies
    * Makes timezones actually work
    * Prevents weird attachments from appearing in your invitation emails
    Although I know that this is a shameless plug for my product, I urge you to give it a try because it will really make your life easier. We have a happy user base, are actively developing new solutions, and are always open to suggestions.
    You can get Zamain for Mac at www.zamain.com.
    Thanks!
    -Jon
    As per the terms of agreement, I must disclose that I may receive some form of compensation, financial or otherwise, from my recommendation or link above.

Maybe you are looking for

  • How to start GC R4

    Hi all, This is Oracle 10.2.0.1 on Linux AS4. I installed Grid Control R2 first then upgraded it to Grid Control R4, the installation was successful. Then I start the dbconsole and I can access database control through localhost:1158. But every time

  • I bought a movie off of itunes and I only got 8 seconds of it!!!!!!!

    This is the second time ive downloaded this movie from itunes (because I lost the movie after going through a big ordeal getting the problems on ipod fixed and Apple is a cheap ******* and will only let you download it once) and now after spending $2

  • How to view unseen pages using Smart Print

    I have a HP Photosmart C4480 All-In-One Printer, running Vista 64-Bit and Windows 9.  Once Smart Print has highlighted text, I have not found the method of viewing text that is out of screen view.  Ex:  An email, including recipients is three pages l

  • LR 4.2 convert or embed color profiles?

    Costco print services use Dry Creek Photo profiles.  They ask that files be converted to color profiles  in PS and say that embedded profiles will be ignored by their digital printers. I wonder if I can do this in LR4.2 without going to PS CS6. In Li

  • Acrobat plugin is missing.

    The Acrobat plugin does not show up in the Chrome plugins page. Neither does Adobe Reader plugin. (But I prefer Acrobat.)     (Current plugins include AdobeAAMDetect, Adobe Flash Player, and AdobeExManDetect.) Same problem with previous (36 non-beta)