How to open a file with approriate program

When I program a project I have a problem of opening a file. For example, If I open a word file I want to call Microsoft Word to open this file or if I open *.mp3 file I want to call Winnamp to open this file etc... I know that VC++ can do that by using ShellExecute() procedure but in Java I don't know how to do that. Can you show me how to do, please.
Thanks.
Duong Ngoc Hieu

You may mostly have to do a JNI Call or Spawn a Process and do it. There is one another way of doing it. Use JNDI to search the Registry to find the Associated Program File, parse the commandline arguements and use it to spawn a Process. But I think you need some thirdparty components for Registry Access using JNDI. Try searching for JNDI Registry Access Components.

Similar Messages

  • How to open a file with the assosiate program on suse????

    i came to know that we can open a file with assosiated program on windows using "cmd /c start filename".
    and i want the same functionality on suse linux.
    in forums i found that "kfm filename" will do fine on linux.
    i tried it on suse but no use at all.
    i would appretiate the quick response and i would be very thankful
    for the same.
    Thanks alot in advance.

    take a look at java.awt.Desktop in the JDK SE 6 http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html.
    See these two methods:
    - void edit(File file)
    - void open(File file)

  • How to open a file with the extension x3f (sigma)

    how to open a file with the extension x3f (sigma)?

    RAW data from the following Sigma cameras is currently supported:
    DP1
    DP1s
    DP2
    SD9
    SD10
    SD14
    If your camera is among these, then simply import the photo as usual. https://helpx.adobe.com/lightroom/help/importing-photos-lightroom-basic-workflow.html

  • Externally opening a file with the program its associated with

    Basically I'm looking to simulate what would happen if you double clicked on something in a windows explorer window. I want to have the operating system open a file with the application that as associated with it.
    how do I do it?

    Have you considered the portability issue?
    Win - Associate by editable user preferences
    Mac - Associate to creation program
    Unix/Dos - Explicitly associate program at command
    Rather than just using exec, you could look into something encapsulated to set which program to use so you could use on other system.

  • How to open a file with a link ?

    I am using servlets to design an application.
    The application supports uploading and downloading of .DOC and .RTF files.
    My problem is that I am opening an uploaded file via a link.
    OPen File
    The above is also working fine and opens the file in the IE browser.
    But my problem is that I want to open the file with MS-Word...as is done on many resume-building websites.
    1) How am I supposed to do that ?
    2) Can I specify ContentType="application/msword" in a link ?
    Please Help !!

    I did the foll. w.r.t a docbase.
    A docbase stores documents and assigns an unique id to each one. The foll. is a code snippet that opens a document's contents in a browser.
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    Connection conn = null;
    Statement stm;
    ServletOutputStream sos = null;
    ResultSet res;
    // .... get id of document u want to open
    query = "select id from .. where object_name = ' xx' .."
    res= stm.executeQuery(query);
    Blob blob = res.getBlob("_content"); // this will get content of document identified by id
    int blobLen = (int)blob.length();
    //the foll. is the part u need..
    if (blobLen > 0) {
    InputStream contents = blob.getBinaryStream();
    response.setContentType("application/msword"); // MS Word
    byte[] buf = new byte[blobLen];
    int length = -1;
           while ((length = contents.read(buf)) != -1){
              sos = response.getOutputStream();
              sos.write(buf,0,blobLen);
    sos.flush();
    System.out.println("Doc Received");
    contents.close();
      res.close();
      conn.close();
    }

  • Opening .doc files with wrong program

    Hi *,
    first I've installed open office. A few month later I installed micorsoft office. After that I converted all office files. Everything was working fine. Now my mac forgot to open .doc files with ms word, he chooses oo word. I do'nt have these problems with .xls files.
    Where are the global settings that I can tell my mac to open .doc files with ms word (I will not use "open with" each time;-)
    Thanks in advance
    Michael
    Message was edited by: MichaelLudt

    Select the file. Do a "Get-Info" from the File menu. (command-I). In the drop down menu "open with" select the program and then confirm you want all files like these to open with that program.

  • How do open PDF file with Adobe Reader?

    I failed to open PDF file with Adobe Reader? Please show how to fix it.

    Mac or Win? OS and Reader versions? Where is the file and how did you try to open it? What happened when you tried? Any error messages? Details, please.

  • How to open TXT file with excel 2007

    With Excel 2003  if we right click the txt source file name, there will be an option to open the file Excel, but with Excel 2007, then we right  click txt fiel name , there is no option of open the file with excel, is this mean that we have to copy the txt file to excel file to manipulate the source file? Any idea how to do this?

    just find out that we can use the browser to find the excel and open the file, next time the excel option will be there.

  • How to open a file with the same name?

    Hi, now I practicing making web pages where I put sample codes in one directory and I copy them to edit.
    The probrem is, I couldn't open one file while I'm opening another file with the same name.
    Is it possible to open  a file with the same name in Dreamweaver?

    That could be a very error prone practice.
    May I suggest you take advantage of DW "Snippets" feature instead.
    Simply save any blocks of code you will reuse regularly as snippets,
    and give each one a descriptive name you like.
    Then you can simply place your cursor in code view where you wish the code,
    and click insert on the selected item from the snippet panel.

  • How to open a file with a specific program

    I would like to do this in applescript instead of the terminal. I would like to pick the application and the file in the same command so to avoid opening a blank document.
    open -a textedit /Users/mac/Desktop/GNPRC.doc

    Both of the previous solutions open the "GNPRC.doc" document. However, only the first one returns a result:
    *tell application "TextEdit" to open POSIX file "/Users/mac/Desktop/GNPRC.doc"*
    *get result* --> document "GNPRC.doc" of application "TextEdit"
    *tell application "Finder" to open POSIX file "/Users/mac/Desktop/GNPRC.doc" using (path to application "TextEdit")*
    *get result* --> AppleScript Error — The variable result is not defined.
    Message was edited by: Pierre L.

  • How to open a file with a .bbb extension?

    How do you open a a file with .bbb extension on a Mac?

    ibopyoubopwebop wrote:
    What happens if i decide to buy a non BB phone.
    You can restore only to a BlackBerry device, and then once you copied what you wanted to the storage of your choice (computer or cloud). you can then copy it to whatever device you choose.
    But to get the information from the backup file, you will need to use a BlackBerry 10 device
    Using the Playbook and the Z10 and the Z30 and loving them
    Martin

  • How to open a file with C# for wp8

    I have a downloaded file (downloaded by my app) for instance a doc or a pdf.
    How is possible to open it from my WP8 application using C#?
    Thanks

    Hi SeDevWP,
    If you have installed a app that can open your file on your phone, then you can open it on your Windows Phone 8 application, for example, if you want to open a pdf file in your application and you have installed the Adobe Reader,
    then you can use the following code to open the pdf file in C#:
    private async void Button_Click(object sender, RoutedEventArgs rea)
    StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
    StorageFile pdffile = await local.GetFileAsync("file.pdf");
    // Launch the pdf file.
    Windows.System.Launcher.LaunchFileAsync(pdffile);
    For more information, please try to refer to this document:
    http://msdn.microsoft.com/library/windows/apps/jj206987(v=vs.105).aspx .
    If you do not installed a app that can open your file on your phone, then maybe you need to check some third-party library to meet your requirement.
    Best Regards,
    Amy Peng
    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.

  • How to open pdf file with command?

    I had trouble to open local pdf file with command by WebBrowser control in IE.(The Acrobat version is 6.0 or 7.0 in my PC)
    The pdf command can be getted in this:
    http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf
    I open a local pdf file in IE with pdf command "#Page=3&Pagemode=thumbs" firstly, and then I open the same pdf file without pdf command in other IE, but the second times the pdf file in WebBrowser still show page=3, other than page=1.
    That is to say, the pdf command will affect others WebBrowser process after set .
    <HTML>
    <HEAD>
      <title>WebBrowser</title>
    </HEAD>
    <body bgColor="#999999" MS_POSITIONING="GridLayout">
        <script language="javascript">
            function Input6()
          var oWebBrowser = document.getElementById('oWebBrowser');
       oWebBrowser.Navigate("D:\\Project\\Data\\PDF\07000001.pdf#Page=3&Pagemode=thumbs", null, null, null, null);
        </script> 
        <form id="MethodTest" method="post" runat="server">
            <OBJECT id="oWebBrowser" style="Z-INDEX: 108; LEFT: 10px; WIDTH: 880px; POSITION: absolute; TOP: 72px; HEIGHT: 600px"
        classid="clsid:8856F961-340A-11D0-A96B-00C04FD705A2" VIEWASTEXT>
          <PARAM NAME="_Version" VALUE="65536">
          <PARAM NAME="_ExtentX" VALUE="18521">
          <PARAM NAME="_ExtentY" VALUE="23230">
          <PARAM NAME="_StockProps" VALUE="0">
            </OBJECT>
         <fieldset style="Z-INDEX: 103; LEFT: 250px; WIDTH: 275px; POSITION: absolute; TOP: 6px; HEIGHT: 56px; visibility: visible;">
             <legend>Open Pdf</legend>
             <input type="button" name="Open" value="Open" style="LEFT: 110px; WIDTH: 50px; POSITION: absolute; TOP:20px; HEIGHT:25px;" onClick="Input6()" />
         </fieldset>
        </form>
    </body>
    </HTML>
    Please help me .Thanks.

    It is only appear in Acrobat 6.0 and 7.0.

  • How to open PageMaker files with InDesign CC ?

    I need to open PageMaker 6.5 files with InDesig CC.
    Please, give me a solution.

    From creative cloud desktop Install indesign cs6 (adobe creative cloud allow you to install both indesign cs6 and indesign cc on your computer)
    See: Download InDesign CS6 from CC
    http://forums.adobe.com/message/5485418#5485418

  • How to open alias files with applescript in Powerpoint?

    I would like to do something like this:
    set F to choose folder
    tell application "Finder" to set P to (files of entire contents of F whose name extension is "ppt")
    repeat with oneFile in P
              tell application "Microsoft PowerPoint"
      activate
                        open (oneFile as alias)
              end tell
    end  tell
    It works fine if all files are regular files.
    But I want/need it to work also, if some of the files are aliases (icon has the little pointer in Finder).
    Could some kind soul explain to me what I would have to do?
    TIA.
    Gabriel.

    Are you saying this doesn't work? Generally applications don't/shouldn't care about whether you pass them an actual file or an alias.
    In either case, it's not hard to dereference the alias back to the original file:
    set F to choose folder
    tell application "Finder" to set P to (files of entire contents of F whose name extension is "ppt")
    repeat with oneFile in P
              if class of oneFile is alias file then
                        tell application "Finder" to set oneFile to (original item of oneFile)
              end if
      open oneFile
    end repeat
    Note that I've just specified 'open oneFile' rather than targetting PowerPoint directly - there's no need to target PowerPoint if it's the default application for .ppt files. However, there's no problem telling PowerPoint to open the file if you prefer.

Maybe you are looking for

  • How can i get the random values from database?

    Hi, i want to get random values from database. I try my best find no solution plz give solution in either sql query or java method. thanks in advance.

  • Why can't I use my password on app store,but it works on my computer?

    Today I got my iPad Mini and I started to set up things for the appstore. Then I entered the apple ID and password ,but it says "Can not connect to App Store." I looked online to see if my password was right, and it was but it still didn't work on th

  • Replace OUTLOOK HOME AND BUSINESS Version with OUTLOOK PROFESSIONAL [Standalone]

    Hey Techies, Here is the Scenario,I have been using Office Home and business 2013(installed from Click-to-run setup)  on my WIN-7 pro. As i needed to access my Microsoft Exchange online archive (i have exchange online plan 2) on Outlook i'd to buy ou

  • ITunes setup/installation not loading (Windows 7 64 bit)

    So I uninstalled iTunes because it wasn't able to recognize my iPhone for some reason even though Windows would (and it could be viewed in the 'Computer' folder). At first I could take pictures off of the phone by navigating through these folders: Co

  • Sheet tab name

    Hi report experts, I have a small problem in Oracle Reports 10.1.2.3.0 and Excel 2007. When I have created a paper layout report and tries to run that rdf-file on my client PC with parameters: * desformat='spreadsheet' * destype=FILE * desname='c:\te