Hi,
I'd like to know how to open for example a .doc file with java.
I want word to open the file when I start my program.
Any help?

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.

Yes I can do that, but what if I want to open a specific word document?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.