How to open a .doc file in MS word?

Hello
Can any body direct me to any api or library or sample, where by if you have word document in your local machine, you can run a java program to open that file in MS word. Basically Microsoft word is opened with the local file in your machine and displayed to the user.
I looked for a while on this, could find anything...
Your help is really appreciated.
Thanks
Jeevan

>
Can any body direct me to any api or library or sample, where by if you have word document in your local machine, you can run a java program to open that file in MS word. Basically Microsoft word is opened with the local file in your machine and displayed to the user.>[Desktop.open(File)|http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html#open(java.io.File)]. (Note that here - a word Doc would be opened in Open Office - but that is more useful since Word is not installed.)
>
Your help is really appreciated.>For my part, your thanks are best expressed by assigning [Duke stars|http://wikis.sun.com/display/SunForums/Duke+Stars+Program+Overview] to the answer, and marking it as 'correct' or 'helpful'.

Similar Messages

  • How to open a ".doc" file with ms word directly with this servlet?

    Here is a servlet for opening a word or a excel or a powerpoint or a pdf file,but I don't want the "file download" dialog appear,eg:when i using this servlet to open a word file,i want open the ".doc" file with ms word directly,not in IE or save.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class OpenWord extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doPost(request,response);
    public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException {
    String strFileName = req.getParameter("filename");
    int len = 0;
    String strFileType1 = "application/msword";
    String strFileType2 = "application/vnd.ms-excel";
    String strFileType3 = "application/vnd.ms-powerpoint";
    String strFileType4 = "application/pdf";
    String strFileType = "";
    if(strFileName != null) {
         len = strFileName.length();
         if(strFileName.substring(len-3,len).equalsIgnoreCase("doc")) {
              strFileType = strFileType1;
         } else if(strFileName.substring(len-3,len).equalsIgnoreCase("xls")) {
              strFileType = strFileType2;
         } else if(strFileName.substring(len-3,len).equalsIgnoreCase("ppt")) {
              strFileType = strFileType3;
         } else if(strFileName.substring(len-3,len).equalsIgnoreCase("pdf")) {
              strFileType = strFileType4;
         } else {
              strFileType = strFileType1;
    if(strFileName != null) {
         ServletOutputStream out = res.getOutputStream();
         res.setContentType(strFileType); // MIME type for word doc
    //if uncomment below sentence,the "file download" dialog will appear twice.
         //res.setHeader("Content-disposition","attachment;filename="+strFileName);
         BufferedInputStream bis = null;
         BufferedOutputStream bos = null;
         String path = "d:\\"; //put a word or a excel file here,eg a.doc
         try {
         File f = new File(path.concat(strFileName));
         FileInputStream fis = new FileInputStream(f);
         bis = new BufferedInputStream(fis);
         bos = new BufferedOutputStream(out);
         byte[] buff = new byte[2048];
         int bytesRead;
         while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
         bos.write(buff, 0, bytesRead);
         } catch(NullPointerException e) {
         System.out.println ( "NullPointerException." );
         throw e;
         } catch(FileNotFoundException e) {
         System.out.println ( "FileNotFoundException." );
         throw e;
         } catch(final IOException e) {
         System.out.println ( "IOException." );
         throw e;
         } finally {
         if (bis != null)
         bis.close();
         if (bos != null)
         bos.close();

    Hello!
    Does some one of you had open a MS word file (.doc) in Java search for a token like [aToken] replace it with another text and then feed it to a stream of save it?
    I want to build a servlet to open a well formatted and rich on media (images) ms word document search for tokens and replace them with information form a web form.
    Any Ideas?
    Thank you in advanced.

  • How to open a .DOC file with MS-Word ?

    Hye fellow Java freaks,
    I have made an application to upload .DOC and .RTF files to the server using servlets and the Jakarta Commons FileUpload package.
    The files are uploading successfully.
    Now, I want to place a link to the most recently uploaded file and then, on clicking that link, I want the file to open not in the browser, rather with MS-Word.
    What is the servlet code that I should implement to accomplish this ?
    Any suggesions ?
    Thanx in advance.

    I think this is a client-side issue - how the browser chooses to deal with the .doc file it receives.
    You can 'save as' and then open the file by hand.
    --Jon                                                                                                                                                                                                                                                                                                                               

  • How to open a doc file using jsp Anchor tag

    when i am trying to open a doc file using a jsp it is opening with out proper alignment.
              how to open a doc file with proper alignment using Anchor Tag in JSp Page
              

    Hello!
    Does some one of you had open a MS word file (.doc) in Java search for a token like [aToken] replace it with another text and then feed it to a stream of save it?
    I want to build a servlet to open a well formatted and rich on media (images) ms word document search for tokens and replace them with information form a web form.
    Any Ideas?
    Thank you in advanced.

  • I recently updated my OS to OS X. I had to update my word and powerpoint etc... to 2011 version, but now when I want to open a .doc file made in word 2003 it removes all the text in it! I did not back anything up!

    I recently updated my OS to OS X. I had to update my word and powerpoint etc... to 2011 version, but now when I want to open a .doc file made in word 2003 it removes all the text in it! I did not back anything up! All my mums work is on there for her job and now she cant use it! I need help fast!

    If you updated from 2003 that must be on a Windows machine, can you recover them from there?

  • How to open a doc file

    Suddnely doc files have stopped opening!

    Please perform the below shown steps to resolve the issue
    1. Turn OFF the Notebook
    2. Power ON the Notebook and keep tapping the F8 Key
    3. Select "Last known good configuration from "Advance Boot Options" list
    4. Please remove Startup items and Uninstall if there are any unwanted applications
    5. Please reboot/restart the Notebook once
    **Click the KUDOS star on left to say Thanks**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.
    Thank You,
    K N R K
    I work on behalf of HP

  • How to open a log file form a frame in linux

    Hy,
    Can anyone knows how to open a pdf file in linux from java?? and also a conf file(when I try Runtime.getRuntime().exec("path") -gives me an error like -I don't have the right to open that file , how can I open that file as root??)
    Thanks in advance

    Are you familiar with java.awt.Desktop?
    http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html
    Try its open() method.

  • How to open a pdf file and then attach it with images

    I am new to Indesign Server.
    I'm currently working on a pdf.
    I have a white blank pdf template.
    that I want to attach/glue it with images.
    How to open a pdf file and then attach it with images.
    Please, help me.
    Thanks.

    First step would be to make yourself familiar with InDesign desktop version.
    Whatever you intend to achieve, do it there manually. (see regular app docs or forums)
    Then try to automate your steps with scripting (see scripting docs or forum)
    If you can do it with a script in the desktop version, that script will likely also run in ID Server. (see server forum).
    If you can specify missing features not achievable thru scripting or manual use, reconsider to write a plugin (this forum).
    A seasoned C++ programmer will need a few months to learn the basics, wade thru tons of documentation etc. Alternatively consider to hire a consultant to do the development work for you.
    Dirk

  • Can't open .doc files in either Word or Pages!! Any suggestions?

    So I stated having issues with Word not being able to open my .doc files along with a few other things. This prompted me to purchase pages only a few hours ago hoping that it would solve all my problems. Unfortunately this did not solve my problem and now I still can't open them even in pages. Any suggestions?
    I have OS X 10.6.8. Any help would be greatly apreciated as I am a new Grad student and need to be able to access .doc files that are posted online.

    Ok I forgot to try to hit Open With for Word and that worked for one document but I still want to know how to get it open in pages.
    Well you can do the same thing for Pages. From the Get Info window, choose Pages for Open With.
    But you should also be able to:
    drag a Word document and drop it on the Pages icon or
    Launch Pages, choose File > Open, find the Word document using the Open box and click Open.
    If neither works please explain what steps you're following and what happens.
    Thanks.

  • Problem in opening a doc file using Runtime.exec()

    Code:
    import java.io.*;
    class StreamGobbler extends Thread {
        InputStream is;
        String type;
        StreamGobbler(InputStream is, String type) {
            this.is = is;
            this.type = type;
        public void run() {
            try {
                InputStreamReader isr = new InputStreamReader(is);
                BufferedReader br = new BufferedReader(isr);
                String line=null;
                while ( (line = br.readLine()) != null) System.out.println(type + ">" + line);   
            catch (IOException ioe) {
                 ioe.printStackTrace(); 
    public class GoodWindowsExec {
        public static void main(String args[]) {
             String file = "test.doc";
             String appPath = "/C";
            try {
                String osName = System.getProperty("os.name" );
                System.out.println("OS : " + osName);
                String[] cmd = new String[3];
                if( osName.equals( "Windows NT" ) || osName.equals( "Windows XP" )) {
                    cmd[0] = "cmd.exe" ;
                    cmd[1] = appPath;
                    cmd[2] = file;
                else if( osName.equals( "Windows 95" ) ) {
                    cmd[0] = "command.com" ;
                    cmd[1] = appPath;
                    cmd[2] = file;
                Runtime rt = Runtime.getRuntime();
                System.out.println("Execing " + cmd[0] + " " + cmd[1] + " " + cmd[2]);
                Process proc = rt.exec(cmd);
                // any error message?
                StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR");           
                // any output?
                StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT");
                // kick them off
                errorGobbler.start();
                outputGobbler.start();
                // any error???
                int exitVal = proc.waitFor();
                System.out.println("ExitValue: " + exitVal);       
            catch (Throwable t) {
                t.printStackTrace();
    }I got this code from internet. Program will work fine if my "test.doc" is in "C:\test.doc" directory. Is there any way to get the application path and open the doc file or how to give a specified path for my doc file
    EG:- "C:\TestDir\test.doc"
    Thanks

    Well /C is not the path to the app. It is a switch to
    the command line.
    set your file name to "C:/test.doc"
    ~TimSorry, I guess my reply doesn't really answer the problem. But you can supply the entire path as part of the file name string.
    String file = "C:/Path/To/My/File/to execute/test.doc"

  • How to open an .indd file in commands

    does any one know how to open an .indd file in commands from a plugin(without opening from the normal procedure..File -> Open ...)
    in my plugin I tried,
      SDKFileOpenChooser fileChooser;
    fileChooser.AddAllFiles();
    fileChooser.ShowDialog();
         It shows the dialog window to choose a file. but i don't know what to use that file to be apperead in Indesign application.
    If you have any idea please let me know..

    Here's a sample function I use:
    // Create an OpenDocCmd:
            InterfacePtr<ICommand> openDocCmd(CmdUtils::CreateCommand(/*kOpenDocCmdBoss*/ kOpenFileCmdBoss));
            if (openDocCmd == nil)
                break;
            // Get an IOpenFileCmdData Interface for the OpenDocCmd:
            InterfacePtr<IOpenFileCmdData> openFileData(openDocCmd, IID_IOPENFILECMDDATA);
            if (openFileData == nil)
                break;
            // Set the IOpenFileCmdData Interface’s data:
            openFileData->Set(docSpec, uiFlags, openFlags ,IOpenFileCmdData::kNotUseLockFile);
            // Process the OpenDocCmd:
            error = CmdUtils::ProcessCommand(openDocCmd);
            if (error)
                break;
    // Create a layout window for the new doc:
            InterfacePtr<ICommand> newWinCmd(CmdUtils::CreateCommand(kOpenLayoutCmdBoss));
            newWinCmd->SetItemList(UIDList(*openDocCmd->GetItemList()));       
            error = CmdUtils::ProcessCommand(newWinCmd);
    Make sure of error checks!
    OR Search for SDKLayoutHelper Class Reference

  • Firefox keeps aksing me what programs that i want to open a doc.file with every time i try to download a doc file.

    the program that I use is open office. I chekced the box that says that this will always open a doc file but it keeps asking me about it.

    Firefox should be able to remember your preference -- as long as the site is specifically identifying the file as a distinct content type. Some sites may fail to do this and simply indicate it is a binary file that the browser can't handle, in which case Firefox doesn't store a specific preference.
    So this could be a problem caused by how the server is identifying the content type. Or it could be a problem with the settings file that stores download preferences. The workaround for that problem is to remove the file and have Firefox rebuild it. If you have changed settings from the default (for example, how to view PDFs) you will have to change those settings again.
    If you want to try it:
    Open your current Firefox settings (AKA Firefox profile) folder using
    Help > Troubleshooting Information > (in the first table) "Show in Finder" button
    Leaving that window open, switch back to Firefox and Exit/Quit
    Pause while Firefox finishes its cleanup, then rename '''mimeTypes.rdf''' to something like mimeTypes.old
    Restart Firefox and see whether its memory improves.

  • How to open Microsoft office files from my wp8 app?

    Is there any way to open Microsoft office documents? I want to open a doc file which is in my phone.My app may try to open pdf also. So is there any way for that? I need a free one.

    //where file is your StorageFile type object of perticular //Office documents i.e. ppt or doc etc
    await Windows.System.Launcher.LaunchFileAsync(file);
    Please Refer these links 
    How to open pdf file in Windows Phone 8?
    Launcher.LaunchFileAsync
    shah
    // Please Mark as answer if it is Helpful to you. Thank You

  • How to open a specific file in projector.

    Hi to all
    can any body tells me that how to open a specific file in
    projector with an application not in browser????
    and also want to add a button to mute the sound just like in
    intros with fade in and out effect.
    its urgent....
    Thanks in advance

    Hi,
    You can use FlashJester JStart
    http://jstart.flashjester.com
    that will open up any file the has been associated in Window
    Explorer.
    Download a FREE evaluation copy and try it for yourself.
    Please look at the example files given.
    Regards
    FlashJester Support Team
    e. - [email protected]
    w. -
    http://www.flashjester.com
    There is a very fine line between "hobby" and
    "mental illness."

  • "uses a file type that is blocked from opening in this version" error message when opening a *.doc file with Word already running

    Several customers running different versions of Office 2011 (14.4.1-14.4.5) on OSX varying from 10.7.5 to 10.9.5, running on various kinds of hardware (iMac/MacBook Pro/MacBook Air) of various ages are having issues opening *.doc files if the Word is already open. The error message that gets displayed is, "XXXX.doc uses a file type that is blocked from opening in this version"
    When the customer tries to open the same file via File-Open, she gets "The file is locked for editing. you can open the file as read-only".
    When trying to do so, she gets "Word cannot open this document. The document might be in use, the document might not be a valid Word document, or the file name might contain invalid characters".
    If Word gets Force-quit, the same document opens without any problems.
    1. Repairing Disk permissions was ran several times. and the volume was found to be OK.
    2. I have noticed that in this scenario either deleting the normal.dotm or com.microsoft.word.plist (~/Library/Preferences) sometimes resolves the issue, sometimes it doesn’t. There is no pattern to follow. All versions of Office are affected, the fully updated and the non-updated ones.
    3. I have tried completely removing the suite using Office 2011 Uninstall.app and/or Remove Office 2011 Uninstaller.pkg, then going through customer's library and manually removing all the Office references.
    4. None of these systems had Office 2008 in the past.
    Any help will be greatly appreciated.

    Reboot both the Mac and the server. Word opens .DOC files and Excel opens .XLS files. As you have found out by copying the files to the computer. It is the connection between the 2 computer that is causing the error.

Maybe you are looking for

  • No Infopackage available in Load process (In Process Chain)

    Hello All, We have a problem in process Chain, When we add the load Process Item and want to see all the infopackage available, the system say no data... We have Infopackage on Datasource vs 3.x and Datasource BI7. Thanks in advance for your help.

  • Mail can't send mail on home network

    I am trying to help a friend who wants to move from Entourage to Mail. He has a MacBook Pro with 10.6.4 installed and his company uses Exchange 2003. He is moving to Mail due to serious calendar and contact syncing issues through Entourage and his iP

  • Sniffer_gpu error/crash only when non-admin is logged in

    I successfully installed Adobe Master Collection CS4 on our lab machines at school, WIn XP Pro (machine has all MSFT updates).  Worked great for ANY local administrator.  But when a student, a NON-local admin logs in, he/she gets sniffer_gpu error wh

  • How do I set the ammount of URL's that will show when you click the drop down bar?

    I remember before I was able to set a certain amount of URL's that would show in the drop down menu. before I had 10 set and then I downloaded an add on and now it's only 4. I disabled that add on and it's still only 4.

  • How do I disable yahoo contact sync?

    After installing 10.7.2 on my 2010 21.5 iMac, I started getting popup Yahoo windows asking if I wanted to sync my contacts.  I keep clicking cancel but every 15 min or so, the same window comes up.  I have checked my address book and I have it set to