• Post Reply Bookmark Topic Watch Topic
  • New Topic

launch msword from java  RSS feed

 
Anand Shrivastava
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,

How can we launch msword from java program to open an already existing file.

Kindly help.
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Runtime.exec()
 
Anand Shrivastava
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

I am using the command like this

Runtime.getRuntime().exec("start " + filename);

but I get the following error

cannot run program start:create ProcessError 2, cannot find the file specified

However, i have given the full pathname of the file in filename

Please help
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
start is not a command by itself, but only in the Windows Command Prompt.

Try "cmd /c start " + filename instead. This will tell cmd to execute start + filename
 
Anand Shrivastava
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
after doing this it is not opening msword, but it only opens the explorer window.
 
Anand Shrivastava
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have traced the problem.

Actually the filenames are so big that they are getting stored in ~1.doc form. for eg. the filename is 1237-88. It gets stored like 1237-8~1.doc.

How should i address such filenames. is there any method by which i can address both this kind of longer filenames as well as shorter filenames.
 
Bert Bates
author
Sheriff
Posts: 8954
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sliding this over to the intermediate forum...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!