Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

open up a word document with Ms Word

From Java, it is very easy to open up another program (thanks to Venci75). But what happen if open another program with its own file?

For example, if i want to open up a document file (.doc) with Ms Word from java, what should be the code look like?
0
Heliumyap
Asked:
Heliumyap
  • 4
  • 2
1 Solution
 
Venci75Commented:
try this:

Runtime.getRuntime().exec("cmd /c start c:/temp/kiki.doc");
0
 
Venci75Commented:
I mean:
Runtime.getRuntime().exec("cmd /c start c:/...<the path to your document>");
0
 
HeliumyapAuthor Commented:
Wow! it work! But what does "cmd /c start" mean? Could you explain abit?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
HeliumyapAuthor Commented:
does cmd means the command in dos prompt?
0
 
Venci75Commented:
this actually is a thrick. This starts the command promt. /c means that the commands after that will be executed and after that the command prompt will be closed. Now I am actually looking for a better way - that doesn't show the command promt, but with no success til now
0
 
Venci75Commented:
aha - I found it:
Runtime.getRuntime().exec("explorer c:\\temp\\my_doc.doc");

this force the windows explorer to find the application for this document, and open the document with it
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now