How to run doc file in Java?

Showing Answers 1 - 8 of 8 Answers

Guest

  • Jan 3rd, 2006
 

The question is a bit ambigiuos.I understood that you want to open doc(MS-WORD) file using java program.Am I Right?

Anyhow if u want to open non-java application,You can use class java.lang.Runtime class.

The following java program opens a word file named 'OAFAQs.doc'.

import java.io.*;

public class Doc
{
 public static void main(String[] str)throws IOException
 {
  Runtime rt = Runtime.getRuntime();
  Process p = rt.exec("C:\\Program Files\\Microsoft Office\\OFFICE11\\WINWORD.exe   OAFAQs.doc");
 }
}

Here the "C:\\Program Files\\Microsoft Office\\OFFICE11\\WINWORD.exe" is the executable file for MS-WORD.

  Was this answer useful?  Yes

Sreeni

  • Feb 21st, 2006
 

There are two kinds of Javadoc comments: class-level comments, and member-level comments. Class-level comments provide the description of the classes, and member-level comments describe the purposes of the members. Both types of comments start with /** and end with */.

  • @author: Describes the author of the document. Used in class-level comments
  • @param: Describes a parameter of a method or constructor.
  • @return: Describes the return type of a method.
  • @throws: Describes an exception a method may throw.
  • @exception: Describes an exception.

  Was this answer useful?  Yes

anshuman

  • Apr 15th, 2007
 

I have used your source code
it opens the word software but it does not open the file
it is saying that permission is not there
pls provide some help on it

  Was this answer useful?  Yes

Here is the correct code for this. Save anywhere your document file it search and open.

import java.io.*;
public class Example {

    public static void main (String[] args) throws IOException
        {
            Runtime rt=Runtime.getRuntime();
   
             rt.exec( "C:Program FilesMicrosoft OfficeOFFICE14WINWORD.exe notes.doc" );  
   
        }
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions