Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Inspire Harmony Between COM and Java with JCOM : Page 3

There are so many application extensions you can build with Microsoft Office applications using COM, but that's no use to Java developers … unless they have a handy Java-to-COM bridge. Using JCom you can control just about any COM object from within Java, plus it comes with some great helper classes for Excel right out of the box.


advertisement
Going Beyond Excel
Remember JCOM is all about COM and not just Excel. Using this toolkit you can control just about any COM object from within Java. Excel is generally the most commonly controlled one, and as such there are nice helper classes to make it easier, but all COM components are available. So controlling other application such as Word or Powerpoint is straightforward too.

Here's an example using Word:

IDispatch wdApp = new IDispatch(rm, "Word.Application"); wdApp.put("Visible", new Boolean(true));

As there is no direct helper class for Word, everything is done through the IDispatch object (which is exactly what the underlying helper classes do for Excel). The code above will launch a copy of MS Word and make it available for automation through the wdApp object. You can then play with Word using method such as the 'put' (for setting properties) or 'method' (for calling methods). For example the code above sets the Visible property to true, making the Word app visible.



If you're going to be bound to Windows, there is a wealth of COM components out there to expand your horizons beyond what Java currently offers. Hardware control through the serial or parallel ports can be a snap using the right drivers and now you can do it in Java. And that's just the beginning. With JCOM in your toolbox, the sky is the limit.



Laurence Moroney is a freelance enterprise architect who specializes in designing and implementing service-oriented applications and environments using .NET, J2EE, or (preferably) both. He has authored books on .NET and Web services security, and more than 30 professional articles. A former Wall Street architect, and security analyst, he also dabbles in journalism, reporting for professional sports. You can find his blog at http://www.philotic.com/blog.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap