Open a file with its defualt associated application

is there any way to open any file with its defualt associated application from a java program ?
Example:
In Windows I have a file example.txt and, from a java program, I would like opening it by the defualt associated application Notepad.
Thx

Take a look at this thread:
http://forum.java.sun.com/thread.jsp?forum=31&thread=161228

Similar Messages

  • Opening a file with its filename from a servlet- avoid buffer to cach files

    Hi,
    I am building an URL with the following code and calling that particular file from this servlet using request dispatcher. When I am geting alcCode from getParameter method then it is not caching the pages
    but when I am geting the same through a session value it starts caching the page after cirtain number of requests and shows up the previously requested file.
    I guess it is because it always names the file with the package name.
    for example if my package is sree then the file opened is named as
    sree[1].pdf. Please help me solve this problem
    alcCode = req.getParameter("alcList");
    HttpSession userSession= req.getSession(false);//if request is from //submit action from a FORM
    String alcCode;
    alcCode = req.getParameter("alcList");
    System.out.println("request.getparameter alcCode "+alcCode);
    if (alcCode==null){
    alcCode= (String) userSession.getValue("alcCode");
    //else get the alc code from the session that has been stored
    Calendar todaysDate=Calendar.getInstance();
    int selectMonth=todaysDate.get(Calendar.MONTH);
    int selectYear=todaysDate.get(Calendar.YEAR);
    if(selectMonth <10)
    //selectMonth = InvoiceDate.substring(1,i-8);
    urlPdf="/reports/RPTS"+selectYear+"0"+selectMonth+"/PDF-FORMAT/E"+selectYear+"0"+selectMonth+"_"+alcCode+".PDF";
    }else{
    urlPdf="/reports/RPTS"+selectYear+selectMonth+"/PDF-FORMAT/E"+selectYear+selectMonth+"_"+alcCode+".PDF";
    res.setContentType("application/pdf");
    res.reset();
    res.resetBuffer();
    res.setHeader("Content-disposition","attachment; filename" +urlPdf );
    System.out.println(urlPdf);
    try{
    ServletContext sc = getServletContext();
    RequestDispatcher rd = sc.getRequestDispatcher(urlPdf);
    rd.forward(req, res);
    Thanks in advance.
    -Sreekanth Varidhireddy                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I had a similar problem when I used the attachment argument to the Content-Disposition header.
    try replacing this:
    res.setHeader("Content-disposition","attachment; filename" +urlPdf );
    with this:
    res.setHeader("Content-Disposition","inline; filename=" +urlPdf );
    /Niklas

  • I can't set Firefox to open PHP files with Firefox (in preferences- applications-php files) Firefox won't accept anything but "always ask" and Preview. I want to preview php files in Bbedit and that requires that Firefox can open it.

    with an open php file in Bbedit (Macintosh) it was possible to preview appearance by chosing "Preview in.." in Bbedit's "Markup" menu. This called Firefox to open and display the file. Now, doing this continually repeats a "Open with (choose)" request.

    Unfortunately this solution doesn't work for me for local files (on my computer). Still I can only choose to open in Notepad or "other". It seems that I can select Firefox, but it won't do anything when I actually select it.... I did NOT have this problem with the previous version of Firefox (before 6.0.2). The only thing that's changed, is the Firefox update from yesterday (September 28th, 2011).

  • Problem with opening a file in its application using Runtime

    Dear experts,
    excuse me for my ignorance, but I am facing a problem and I would really
    appreciate some help. I am working on a java program in which I want the user
    to have the ability to save the contents of a JTable into a file of his preference (the file could be of any type i.e xls, txt, doc...) and then open this file in its
    default application (i.e the txt file through notepad, the xls file through excel etc..).
    Everything works fine with the code below, if the filePath does not contain blank spaces. I did some search on the forun and the web, and also tried to
    find a solution through the great link
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html but I still
    cannot solve the problem. Below I quote the part of the code (actually the actionPerformed dunction of the equivallent button) which is responsible for the opening of the file.
        excelButton.addActionListener(new ActionListener()
           public void actionPerformed(ActionEvent e)
             //saveFileName is the File that I want to open
             String filePath = "\""+saveFileName.toString()+"\"";
             System.out.println(""+filePath);
             try
              String cmd="cmd.exe /C start "+filePath;
              String cmd="cmd.exe /C start C:\\Documents and Settings\\test.xls";
              Process p = Runtime.getRuntime().exec(cmd);
             }catch(IOException ec){}
         });Thank you in advance for your help!
    Sincerely yours,
    JIM

    Dear BillBlalock ,
    thank you for answer!! You are very kind and helpful!! I would like to inform everybody that I have finally find another way of soilving my problem and I announce it to the forum in case somebody else encounters the same problem. Well, I soved the nproblem by using the following code:
        excelButton.addActionListener(new ActionListener()
           public void actionPerformed(ActionEvent e)
             String filePath = "\""+saveFileName.toString()+"\"";
             System.out.println(""+filePath);
             try
               String cmd="explorer "+filePath;
               Process p = Runtime.getRuntime().exec(cmd);
             }catch(IOException ec){}
         });I hope it can be useful to somebody!! By this code, I can make a button (in my case the excelButton) to open any file in its default application. Keep up the great work you are doing guys!!

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

  • I need to open a file with an associated programm.

    I need to open a file with an associated programm.
    I'm looking for two solutions:
    1. for Linux/Solaris/Unix/...
    2. for Windows 95/98/Nt/2000
    For Windows I have done this with command line
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + uSavePath);
    but it doesn't work on windows2000. We need an universal solution.
    For linux
    Process p = Runtime.getRuntime().exec("netscape openURL " + uSavePath);
    But may be anybody know better solution?

    You are right. For unix better solution is that my program to care about all association itself. As I undestend now it's a common solution for unix applications.
    But for windows it will be ugly enough. I've found another way for windows
    Win2000/NT: "cmd /C start filename /B"
    other Wins: start filename
    for linux I've stopped at doing this via Netscape.
    May be in future I'll make my property file.
    start filename - on Win95(may be 98/ME) returns -1 if file not assotiated with a programm, and doesn't shows openWith dialog. It solved using something like "rundll32 shell32, OpenWith filename"
    It's all for those how will solve this problem in future.

  • I opened a file with angry birds and its now frozen what do i do

    i opened a file with angry birds on accident and now its frozen it wont respond what do i do

    Force Quit .
    Press command + option + esc keys together at the same time.
    Wait.
    When Force Quit window appears, select the application if not already.
    Press Force Quit button at the bottom of the window.
    Wait.
    Application will quit.
    If this does not help, press the power button for 7 or more seconds.
    Computer will shut down.
    Restart.

  • Opening a file in its native application from Flex.

    Is it possible to open a file on whatever native application the user runs it as?  Or even, at that, to simply open the directory it's in, in an explorer window?
    We have a search application and the frontend is in Flex, and I'm trying to find a way to do this, such that when a use double clicks on a result (in a datagrid - but that's trivial), it opens the file or at least the location of the file on the OS.
    Any system call where I can say system("explorer.exe " + filepath); or something?
    Any help would be appreciated.

    Dear BillBlalock ,
    thank you for answer!! You are very kind and helpful!! I would like to inform everybody that I have finally find another way of soilving my problem and I announce it to the forum in case somebody else encounters the same problem. Well, I soved the nproblem by using the following code:
        excelButton.addActionListener(new ActionListener()
           public void actionPerformed(ActionEvent e)
             String filePath = "\""+saveFileName.toString()+"\"";
             System.out.println(""+filePath);
             try
               String cmd="explorer "+filePath;
               Process p = Runtime.getRuntime().exec(cmd);
             }catch(IOException ec){}
         });I hope it can be useful to somebody!! By this code, I can make a button (in my case the excelButton) to open any file in its default application. Keep up the great work you are doing guys!!

  • What application can you use to open a file with the .acc extension?

    What application can you use to open a file with the .acc extension?

    http://www.fileinfo.com/extension/acc

  • When I try to open a file with adobe Bridge it will say that the parent application is not active, how can I fix this??

    When I try to open a file with Bridge the following message appears:
    I already re-installed PS CC and I can open the files trough Photoshop CC but not through bridge.Any advice please??

    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    A screen shot of your settings or of the image could be very helpful too,
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • I can't open a file I just created a week ago and it says pages needs to be updated to open the file but its up to date

    I can't open a file I just created a week ago and it says pages needs to be updated to open the file but its up to date, what do I do?

    You have 2 versions of Pages on your Mac.
    Pages 5.2.2 is in your Applications folder.
    Pages '09/'08 is in your Applications/iWork folder.
    You are alternately opening the wrong versions.
    Pages '09/'08 can not open Pages 5 files and you will get the warning that you need a newer version.
    Pages 5.2 can open Pages '09 files but may damage/alter them. It can not open Pages '08 files at all.
    Older versions of Pages 5 can not open files from later versions of Pages 5.
    Once opened and saved in Pages 5 the Pages '09 files can not be opened in Pages '09.
    Anything that is saved to iCloud and opened in a newer version of Pages is also converted to Pages 5 files.
    All Pages files no matter what version and incompatibility have the same extension .pages.
    Pages 5 files are now only compatible with themselves on a very restricted set of hardware, software and Operating Systems and will not transfer correctly on any other server software than iCloud.
    Apple has removed over 110 features from Pages 5 and added many bugs:
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&sid=3527487677f0c 6fa05b6297cd00f8eb9&mforum=iworktipsntrick
    You can add the icon of the missing Pages on your Dock or open Pages from the Apple menu > Recent Items list.
    Or you can archive Pages 5 so that it doesn't automatically open.
    If you are unhappy about this review/rate Pages 5 in the App Store.
    Peter

  • Open (.sdf) file with SQL server 2005 Management Studio

    In VS2005, I have created a SQL Mobile database, (.sdf).
    Copied that (.sdf) file to Desktop, and when I try to open with SQL Server 2005 management studio, its showing error "make sure the application for the file type (.sdf) is installed."
    How can I open this file with SQL server?
    Regards
    Abinash

    You must install SP2 if using Management Studio Express (http://www.microsoft.com/downloads/details.aspx?familyid=6053C6F8-82C8-479C-B25B-9ACA13141C9E&displaylang=en)Erik Ejlskov Jensen, MCTS: WM App, MCITP: SQL 2008 Dev - http://erikej.blogspot.com
    Please mark as answer, if this was it.

  • Opening a file with FILE_SHARE_DELETE mode (Only on Windows)

    Hi,
    We have an application that imports logs from several 3rd party vendor's applications. Basically what we do is import the logs in real time, i.e we do have a live FileInputstream connection to the log file. Now, when the 3rd party applications that rotate these logs (many of them do when they grow big or scheduled periodically), all unix flavors dont see to have any problem, while the windows does complain that the device or resource is busy and the original application is not allowed to rotate it. When i dug into the native code of windows jvm, i found that the file is not opened in the FILE_SHARE_DELETE mode and only with FILE_SHARE_READ and FILE_SHARE_WRITE modes. When we wrote a separate C++ application the opens a file with FILE_SHARE_DELETE mode, we found that the logs are rotatable.
    Now, how can we instruct the JVM to open a file with FILE_SHARE_DELETE mode? Is there any such implementation already or do i have to come up with another class extending the FileInputStream and use a totally different open method where the file is opened with this mode in the native code?
    Thanks
    Manava

    Hello,
    I think you can write :
    Runtime.getRuntime().exec("start.exe " + MyFileDialog.getDirectory() + MyFileDialog.getFile());
    So, "start.exe" choose the application (not valid for NT machine), ".getDirectory()" return the PATH and ".getFile()" return the NAME.
    Best regards from France
    Thierry

  • Can't open a file with spaces on the filename.

    Lets say I have a file:
    /home/orv/Open - Me - Please.txt
    When I double click to open that file with any program, the result is something like this:
    "Unable to find /home/orv/Open%20-%20Me%20-%20Please.txt"
    I'm not sure what to call that process of converting the file name so I've been unable to google it up to find a fix or a way to change the behavior of the file manager.
    I've checked the settings in Nautilus and nothings there. Any clues? Thank you!
    Last edited by orv (2007-12-14 23:11:59)

    I tried removing everything in my home directory to erase all settings, still the same problem.
    I tried using a different file manager and still the same problem.
    Here's another example of my problem and its quirks:
    Lets say I have a file called:
    /home/orv/I am a Movie.avi
    In nautilus or thunar, double-clicking that file so I can play it with Mplayer will give an error:
    Failed to open file:///home/orv/I%20am%20a%20Movie.avi
    However, when I drag and drop using the file manager into Mplayer, it works.
    So my problem is this automatic conversion of whitespaces into the %20 which I don't know how to turn off.

  • I am unable to open files on amything!!! a box pops up that asks me what do i want to open the file with..every time!! I want files to open when i click on them!! This happens with emails, websites, everything

    I try to open attachments in emails and they will not open! A box comes up asking 'what do I want to open the file with', and it wants me to select from a list of options like - Firefox, IE, Word, Yahoo Browser. When I make a selection (usually Firefox) a new tab opens with a blank page! This always happens on attachments, links, websites......everything!

    These files were lost two years ago.
    That's not consistent with what you wrote in your first message. I can't help you unless I know what's going on. Either you do, or do not, have backups of all the data you want to keep. If you do not, then the first thing you need to do is back up those files. It makes zero sense to do anything else. In order to back up, you'll need either of two things: another Mac, in working order, with a FireWire port and enough space on its internal drive to hold your files; or an external drive, also with enough space.
    On the other hand, if you do have backups, or if you simply don't care about any of the data, then the solution to your problem may be quite simple. All you have to do is boot from your installation disc (your profile says you're running Mac OS 10.5), erase your internal drive, reinstall the Mac OS, then restore your data from backup. You will need to be selective in restoring software, because incompatible software may be what caused the issue.
    But it's also possible that you have a hardware failure, in which case you can't get your computer working again until it's repaired.

Maybe you are looking for

  • Why doesn't my front camera work

    Why doesn't my front camera work

  • BW Upgrade Strategy

    Hello! We are planning to perform a BW upgrade strategy - BW 3.x to BI 7.0. Without enough experience in doing upgrade, an alternative strategy is formed. Will this be possible? 1. Install BI 7.0 on a new box 2. Create connection of BI 7.0 with sourc

  • Since installing Snow Leopard safari autofill won't work

    I have checked the safari autofill preferences and have the top box and bottom box checked (not the middle passwords). This used to work well as soon as I would enter one letter in a form it would complete it.  Now I must type in everything even in w

  • LONG running qurries in oracle database

    HI, How to check LONG running qurries in oracle database ? and also can you please tell me how to check current runnning quries in DB. Thanks, Shyamu.A.

  • Deleting duplicate contacts in iCloud

    Is there a way to delete a duplicate contact in iCloud and not delete the other contact?  I duplicated contacts in iCloud, not my PC.  They are duplicated on my iPhone, but not the PC.  When I delete one, the other is deleted and everything in the cl