Visual Basic or VBScript as Java Scripting Engine

可紊 提交于 2019-12-12 02:45:39

问题


I consider implementing a ScriptingEngine à la JSR223 for Visual Basic or VBScript (because I don't know any implementation, except the abandoned BSF engine from IBM). I know it will take me some native programming, but I don't know where to start.

One idea would be to integrate windows scripting host into java, maybe by using it like an active control, but I can't find any. Is there a public API for Windows Scripting host? Any other ideas?


回答1:


Yes, it is possible to integrate the Windows Scripting into Java, but it's not trivial. The documentation for the Windows Script Interfaces is available on MSDN. The interfaces you will be most interested in are IActiveScript, IActiveScriptParse, and IActiveScriptSite.

There are numerous examples available via a Google search, but not many in Java. These guys have examples, but it uses their Java2Com product. While not Java specific, Dr. Dobbs did a series of articles on implementing these interfaces in .NET. I think you may find the information useful.

There was also an ActiveX script control that shipped with VB6, which made it easier to add scripting to your application. There is an example here of using it from Java, utilizing the JACOB Java to COM bridge.




回答2:


What you essentially is asking for, is how to embed a .NET program inside a JVM. That is a non-trivial task and may be much bigger than you expect.

The JavaScript JSR-233 engine is available by default in Sun Java 6, and you can download adapters for many other languages at https://scripting.dev.java.net/. You can still have a lot of power while staying inside the JVM.

Also it appears that BSF was not abandoned, but donated to Apache Jakarta. http://jakarta.apache.org/bsf/. I don't see any VIsual Basic support on the page, though.



来源:https://stackoverflow.com/questions/3793234/visual-basic-or-vbscript-as-java-scripting-engine

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