Opening a document from a Java app

I need to open a document from my Java app. It is a .rtf file and I would like it to open with the system associated application for rtf files. How should I do that?
I have tried to figure out the Runtime.exec(), but it doesn't do what I need. I have been able to open Notepad or WordPad (oh, yes, I am on a Win XT system) by specifying them in the exec function, but I can't find info on how to let the system choose the program.
Thanks for your help.
Wayne

Take a look at the JDIC project
https://jdic.dev.java.net/
In particular the org.jdesktop.jdic.filetypes.AssociationService class
https://jdic.dev.java.net/nonav/documentation/javadoc/0.9/index.html

Similar Messages

  • Opening a file from a java app (not applet)

    My program can't find the text file I'm trying to open in my stand-alone java app. I am specifying it like this:
    File filename = new File("myfile.txt");
    FileReader = new FileReader(filename);
    It is in the same directly as the class files. It won't find it when it's in a jar file either. I had a similar problem with an applet a lont time ago, but that turned out to be a security issue, which I assume normal apps don't have.
    So, what's up with this?

    If system become larger, there are duplicated files
    can be found in different directories.
    Using classpath may cause problem, if there are
    duplicated file name.
    If you are coding, you should know exact location of
    the file to be opened.
    "system become larger" - huh? You control the classpath on a per-app basis, not one huge monolithic classpath containing all jars/folders for all apps.
    It's common, well-designed practice to use the classpath. It's bad practice to hard-code directory names and expect all deployments of the app to follow the same directory naming convention. I wouldn't want you to dictate to me where to put the file on my hard drive. I should be able to install it anywhere I want, and let it find it (via the classpath, in this instance).

  • Opening a document from a java program.

    Hi,
    Just wondering if anyone could help me???
    I have a simple java GUI based Program and i want to open up a pdf document when i press a button or click on a hyperlink. ( i want it to open in it's own window (ie launch in adobe acrobat reader) and not be displayed in my application itself).
    I have tried using:
    runtime.exec("c:\myfile.pdf");
    But this does'nt seem to work and is returning the following error:
    java.io.IOException: Create Process: c:\myfile.pdf error = 2
    Can't understand why this is'nt working.
    Any ideas??

    thanks,
    Itried this and now nothing happens when i press the button
    Here is my code:
    try
    Runtime.getRuntime().exec("cmd /h Hullo.pdf");
    }catch(IOException e)
    {System.out.println(e);
    }//end catch
    the document is called Hullo.pdf and it is stored on the H drive

  • Open a word document from a Java Application

    Hi,
    Can I open a word document from a java GUI apllication and point to a bokkmark automatically in the word document when opened.

    See this thread:
    http://forum.java.sun.com/thread.jspa?threadID=228332&messageID=810684

  • I can't download videos in Safari. I can't open Adobe documents from Mail or Safari even though I downloaded Adobe from the App Store.

    I can't download videos in Safari? It doesn't tell me why or how to fix it.
    I can't open Adobe documents from Mail or Safari even though I downloaded Adobe from the App Store?

    I can't download videos in Safari? It doesn't tell me why or how to fix it.
    I can't open Adobe documents from Mail or Safari even though I downloaded Adobe from the App Store?

  • Pages 2.0.2 doesn't open Pages documents from ipad

    Pages 2.0.2 doesn't open Pages documents from ipad 2. Document succesfully transferred as Pages document to computer, but Pages 2.0,2 wouldn;t open it. Version too old?

    Pages 2 is iWork '06, two versions behind what the iOS Pages creates. You need to use Pages '09 which you can purchase from the Mac App Store as a stand-alone application or a retail box of the iWork '09 suite.

  • Not able to open office documents from SharePoint site using Forms auth on a Mac with Office 2011

    I posted the same question on the Mac Office forum (http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macstart/not-able-to-open-office-documents-from-sharepoint/7fba517b-ebd1-4e90-a54a-c70c5f035146?tm=1418836613595) but figured it's probably more
    of a SharePoint question so I'm going to try here as well.
    We just discovered an issue where a user logs into a SharePoint site using Forms based authentication.  When clicking on an Office file they get
    'Sorry, this site hasn't been shared with you' message:
    The user can download the file and can also open the file within the browser (Office Web apps).  This SharePoint site is on a Web app that uses mixed authentication (forms for external partners) and Windows/Kerberos for internal employees.
     When logging into this same site as an internal user I am able to open the file just fine.
    I checked the 'Microsoft Document Connection' settings and selected and deselected 'Enable Basic Authentication' and neither helped.  
    I also tried to add the site URL under 'Microsoft Document Connection' -> Add connection -> Connect to a SharePoint site.  When I put the site URL in and click 'Connect', I get an error saying that 'Only connection to SharePoint or OneDrive
    servers are supported' message.  If I try the same thing as an internal user using Windows/Kerberos authentication I am able to connect to the site just fine.
    Any ideas??

    Hi Szamir,
    As you are using Form Based authentication to open the documents from SharePoint site, I recommend to check the things below:
    Make sure that the user has permission to view the documents in the site.
    Please select "Sign me in automatically" when you sign in the login page.
    More references:
    https://social.technet.microsoft.com/Forums/en-US/ae8cc886-c362-4709-8575-07d339144714/not-able-to-open-microsoft-office-documentsdocxxls-etc-from-document-library-in-a-fba-site-in?forum=sharepointgeneralprevious
    http://manojvnair.blogspot.com/2011/06/login-prompt-while-opening-office.html
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Can I set up safari to automatically open PDF documents in the pages app?

    Can I set up safari to automatically open PDF documents from the internet into the pages app?

    No - and you can't open pdf files in the Pages app on the iPad anyway as far as I know. You can export a Pages file as a pdf but you can't open them in Pages.

  • When I try to open a document from my file on Mac OS X the following message appears, with the Bluetooth logo: 'SELECT A BLUETOOTH DEVICE ....Select a device to send file ...' I then have to go to the source of the document, e.g. Pages, to open the file.

    When I try to open a document from my file on Mac OS X the following message appears, with the Bluetooth logo: 'SELECT A BLUETOOTH DEVICE ....Select a device to send file ...' I then have to go to the source of the document, (e.g. Pages), to open the file. Please could someone help?

    The Get Info dialog should look something like this:
    The "Change All" button should be at the bottom of the "Open With" section.  This is how it appears in Snow Leopard.  Other OSX versions many be slightly different.
    If something is changing the setting back to something else you may have a deeper problem than I am able to help you with.  What is appearing in the Open with area before you correct it?
    If the problem is still persisting, instead of double clicking on the file to open it, try right or control clicking and then select Open With and choose the proper app from the list.

  • Open Pages documents from an older version

    I need to open Pages documents from an older version of Pages that I saved to an external drive from a computer that I no longer have access to.  My current operating system is 10.7.5 and I can't upgrade it right now.  I see that Pages 5.0 requires 10.10 or higher and I can't find older versions to download and from what I've read, it doesn't sound like I'd be able to open the old documents with the new version anyway.  I really need these documents. What can I do?

    I found it helpful to convert all my old Pages '08 files to .doc files.  They can be opened by the new version of Pages.
    Since the new version of Pages is no longer back compatible, and so not good for anything you want to keep for a long time, you might consider using an open source word processing application like Libra Office.  That's what I had to do.  After seven years of being a happy Pages user - archiving thousands of files in Pages -Apple has abandoned us.  I no longer think it is wise to use the new Pages and then five years down the road (or sooner) not to be able to open them in a newer version.
    If you would like a quick way to convert your Pages '08 files to .doc, let me know.

  • Will not open a document from a website in another tab.

    When I am trying to open a document from a website link, a new tab opens in the link but the document is not there, the screen is blank. This happen EVERY time. For example, I just wanted to print a coupon from a department store and I clicked on the link, it opened in another tab and it was blank. The way I solve this is I open up Safari or Google Chrome and open the website and I can then get the coupon to show up. Other people have had this same problem with Firefox. I work at a store that uses printed coupons and people come in and tell me this. This also happens with PDF file links.

    The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information.
    Note: ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
    To Reset Firefox do the following:
    #Go to Firefox > Help > Troubleshooting Information.
    #Click the "Reset Firefox" button.
    #Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
    #Firefox will open with all factory defaults applied.
    Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
    Did this fix your problems? Please report back to us!

  • "An error occurred sending the command to the application" When trying to open excel document from outlook 2007

    Error message "An error occurred sending the command to the application" When trying to open excel document from outlook 2007.
    OS: Windows Server 2008 R2
    If I save the document then it opens fine, messing with default file associations does not resolve this problem, I've googled for ir it and some suggest unticking compatibility mode or "run as admin" for excel application, neither is selected in my case.
    Outlook is configured to run as remote application from remoteApp server, this error is only occurring for one user, for others excel documents open just fine.

    Hi
    Thank you for using
    Microsoft Office for IT Professionals Forums.
    From your description, we can Create a trusted location follow these steps
    Click the Microsoft Office Button , and then click Excel Options.
    Click Trust Center, click Trust Center Settings, and then click
    Trusted Locations.
    If you want to create a trusted location that is not local to your computer, select the Allow trusted locations on my network (not recommended) check
    box.
    Click Add new location.
     IMPORTANT   We recommended that you don't make your entire
    Documents or My Documents folder a trusted location. Doing so creates a larger target for a hacker to potentially exploit and increases your security risk. Create a subfolder within Documents or My Documents, and make only that folder a trusted location.
    In the Path box, type the name of the folder that you want to use as a trusted location, or click Browse to
    locate the folder.
    If you want to include subfolders as trusted locations, select the
    Subfolders of this location are also trusted check box.
    In the Description box, type what you want to describe the purpose of the trusted location.
    Click OK.
    More detailed information you can refer to this link:
    http://office.microsoft.com/en-us/word-help/create-remove-or-change-a-trusted-location-for-your-files-HA010031999.aspx?CTT=1#BM12
    Please take your time to try the suggestions and let me know the results at your earliest convenience. If anything is unclear or if there is anything
    I can do for you, please feel free to let me know.
    Hope that helps.
    Sincerely
    William Zhou CHN
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Getting error while opening Excel document from SharePoint site

    Hello All,
    I am getting following error while opening Excel document from SharePoint site.
    This issue appears when we open Excel document from Windows>> Run using below mentioned command:
    Excel.exe "{File Name}"
    If once I go to Excel back stage and browse for the SharePoint location, then this problem disappears.
    I have a work around for this issue but main problem is that i do not have any work around when i need to open Exel document using Excel COM interop in C#.
    Thanks,
    Amit Bansal
    Amit Bansal http://www.oops4you.blogspot.com/

    Hi Amit Bansal,
    Thanks for posting in MSDN forum.
    This forum is for developers discussing developing issues involve Excel application.
    According to the description, you got an error when you open the document form SharePoint site.
    Based on my understanding, this issue maybe relative to the SharePoint, I would like move it to
    SharePoint 2013 - General Discussions and Questions forum.
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.
    Thanks for your understanding.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Sorry, we couldn't open...Error opening office documents from SharePoint 2013 in the desktop applications

    Sorry, we couldn't open...Error opening office documents from SharePoint 2013 in the desktop applications        
    One of our Managers encounters the error 'A problem occurred while accessing the Office document cache.  Do you want to repair this problem?'
    Then When he says yes it give a warning that the cache will be backed up and replaced
    Then it says 'A new office document Cache has been created...'
    Then it loads this cache with an error
    Then After all that the next time he tries to open the document it says  is encountered "Sorry, we couldn't open 'URL."
    We have Reinstalled office 2013 on the users PC repaired the cache numerous times
    Followed -  http://office.microsoft.com/en-gb/word-help/manually-rename-the-office-document-cache-HA101848838.aspx
    Updated Lync to 2013 leaving Access as the only office 2010 application (required for legacy systems access)
    Repair installed office 2010 and office 2013 again
    The SharePoint site has been added to the trusted sites list and the set up assistant run from office 365
    And the issue remains the Same all other users including some who also have Access 2010 for legacy systems access have no Issues OS is windows 7 32 Bit browser is IE 9
    Office 365 said
    Reply by Rachel Zhang MSFT Support
    Hi Alex,
    From your description, I notice that the issue is related to Office client. We would like to help you, but I’m sorry that our forum does not focus on this scenario and has limited resources regarding it. However, we have a dedicated support forum where
    the support engineers will help you with the issues about Office client:
    Microsoft Office Community:
    http://answers.microsoft.com/en-us/office/forum/office_2013_release?tm=1365567547805
    Feel free to sign in to the Office community and click Participate->Ask a Question to post the question with the relevant information.
    Microsoft Office Community:  
    Feel free to sign in to the Office community and click to post the question with the relevant information.
    Office team said
    Hello Alex,
    Thank you for posting your query in Microsoft Office Community.

    Check if other excel works fine
    Do you have any script\macro in excel file
    Check if all application pool on all servers are running
    both office and IE should be same build (64 or 32 bit)
    what is the error message in ULS log and Event viewer
    If this helped you resolve your issue, please mark it Answered

  • I can't turn on Mail in Settings.  Earlier i tried to e-mail a document from the GoodReader app through my Gmail account.  Apparently, my iPad2 didn't like that.  Also, now when i click on Mail on the Home screen, the Mail screen shows no mailboxes.

    iPad2.  I tried to e-mail a document from the GoodReader app.  It froze.  Now, when i tap the Mail button on the Home screen, it goes to a blank mail page, with no mailboxes, whereas before it went straight to my Gmail account.  I went in to the Settings section, tapped on Mail, Contacts, and then on Gmail.  The Mail button is grayed to Off, and when i press it to turn it On, all i get is a message that says Turning on Mail, but nothing happens.  Suggestions?

    Start off by trying to reset the ipad. Press and hold the power and home buttons at the same time until the device powers down and you see the Apple logo.

Maybe you are looking for

  • How to display data in an email the way a form is filled out???!!!

    I am need of proper code to order my data that is filled out in a form to display the same way when it is submitted....currently it is information is all over the place when the form is submitted to an email address Here is what I have: <%@ page impo

  • Audio i/o not working properly after sofware update?

    i've been working along fine with my mac, then after my OS told me there was "security update 2007-005" i thought no problem and installed it, then my motu 828 only plays audio for about 5-10sec pop and clicks sometimes then gives up. i have perfectl

  • Release SO many times

    Hi all, The scenario is after booking sales order, i go to release sales order to run concurrent in order to get the move order number.Then release complete and i got the move order number. But I can release sales order again and again.Is this normal

  • CS4 to CS6 Problem

    I'm currently running the CS4 basic Design Suite (Illustrator, InDesign and Photoshop) and want to get CS6, now. I believe there was a limited period offer allowing that at a discount, but can't seem to find a link for it anywhere, now. As a long ser

  • DSL & Printer Server

    I just installed a WRT54G (ver 6) on a 3 computer network.  All seems well the comptuers (none of them are wirelesss) talk to each other.  My problem(s) are I can not connect to the internet anymore.  If I go to Start, Connect To and choose my ISP I