File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes How to open MS Word from Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to open MS Word from Java" Watch "How to open MS Word from Java" New topic

How to open MS Word from Java

Venkatesh buddala

Joined: Apr 11, 2006
Posts: 2
Hi, Friends
Please slove my problem ..

I want to open Ms-word & load a .doc file when a button clicks from AWT GUI Application.

Actually i want to save my database out put into an ms-word document & open it from Java AWT Application(when a button clicks).

for Generating MSWORD
We generated the db output & add html tags and written into File & save this files with .doc extension. this is solve the problem of generating MSword file & MS-WORD interpreting these files proparly.

But now i want to Open MS-WORD & load the generated file.could you some one please give the solution & also is there any better way to generate ms-word files from java.

Thanks in Advance

Joined: Sep 16, 2005
Posts: 21
You must read POI

Hope this information is useful
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
OK, so you're already creating files that Word can open. In that case you don't need POI. What happens if you stream the word file to the browser - does it not cause Word to be opened, or at least the user to be asked what he wants to do with the file?
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
From the command line, you'd use

start filename.doc

to open word with the file. Executing that line with Runtime.exec should give you the desired result. Of course that only works on Windows...

Not a GUI question, moving to Java in General...

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I agree. Here's the link:
subject: How to open MS Word from Java
It's not a secret anymore!