• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Open Word application or Excel App from Java app.

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi You All,
Can someone please tell me how to open a word application or an Excel application for that matter from a java application and also open the file specified when the application opens automatically. Thanx in advance
Bhaskar
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bhaskar,
Its not possible to write code to do this in java natively (i am open to contrary opinion). The available avenue for you to do this is to do the following:
1. Write a DLL using platform specific compiler that carries out the opening of the file (use VB, VC++, etc) using a simple function name.
2. Create a java class within your application that defines the 'simple function name' defined above as a 'static native' method, and call java.lang.System.loadLibrary(String) ( probably from within a static initializer block) specifying the DLL filepath/name above to cause the DLL to be loaded into the java process space.
This in effect will link up you java application to call the system specific DLL to render the service you desire. This is the way most developers do it.
Akanimo.
[This message has been edited by Akanimo Udoh (edited July 12, 2001).]
 
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
windows only!!
you can open every file with its associated application by calling the 'start' command.
try on cmd prompt: start somewordfile.doc
this opens somewordfile.doc in word.
you can run this trough Runtime.exec(String cmd)

karl
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Here is the sample code.

Runtime r = Runtime.getRuntime();
r.exec("d:\\Program Files\\Microsoft Office 2000\\Office\\Winword.exe h:\\ADDRESS.doc");

Hope this helps.
Vishal Shah
-----------
SCJP2
-----------
 
Bhaskar Selvaraju
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,
Thanks Guys, You blokes are "BEAUTIFUL" . Thanks so much for this help, makes life so much easier for me.
Thanx once again,
Bhaskar
 
Akanimo Udoh
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems I learn something new from javaranch everyday!!!
My thanx too guys for the enlightenment!
Akanimo.
 
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic