Activex from java application?

烂漫一生 提交于 2019-12-31 22:47:50

问题


Is it possible to easily embed ActiveX controls in Java application? Is it worth it. In my next project I should either use existing activex in Java app or have to reimplement everything from scratch, so I'm wondering what will be less hassle.


回答1:


I don't think there's a way to do this without resorting to a third party library. (Or rolling your own, but you did say "easily".)

SWT (The "Standard Widget Toolkit") contains support for embedding ActiveX controls. SWT is an alternative to Swing, though there is a degree of interoperability between them.
Here's an example of embedding Windows Media Player in an SWT window.

Alternatively there's the Jacob project, though I haven't used that myself.

As for "is it worth it?" Well, I can say from experience that SWT makes it relatively easy, but unless your application can gracefully deal with not having them available, by relying on COM components you are losing the ability to run on multiple platforms that makes Java attractive in the first place.




回答2:


It really depends on how much you are going to have to re-implement. The Jacob project is quite good (we use it extensively for automation of Excel and Word), but you have to really understand COM to use it, especially the vagaries of the IDispatch interface (very few people who use ActiveX / COM actually understand COM - they just rely on Microsoft's template generation).

If you are just trying to save yourself some typing for some simple DAO objects, you'll probably be better off re-implementing (heck, you could probably take the DTD and write a script to generate Java code for it).




回答3:


http://www.codeproject.com/KB/cross-platform/javacom.aspx?msg=1776281 might help if you're willing to do stuff by hand...

Doesn't seem quite as flexible though...



来源:https://stackoverflow.com/questions/239395/activex-from-java-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!