views:

53

answers:

2

Hi all,

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?

A: 

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.

Thorbjørn Ravn Andersen
I don't want .NET in Java, just the Scripting Support which was available long before .NET! And the ActiveScriptingEngine is no longer in BSF, since it has been given to Apache, this is correct.
Daniel
+1  A: 

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.

Garett
+1 Good research, thanks for that. I didn't know the Neva Object guys have this already implemented, so I will pay the price of 239$ if I really need this (I won't be able to expose my Java objects cheaper, I think).
Daniel