Is this possible?  I may be totally lost here at what Rhino can do.  Please
let me know if you'd like me to clarify further..or if I am not making any
sense at all.
I guess the question comes down to, can I use Rhino as a command prompt /
command line interface to control my application.

Yes, I think you can. Based on my fumblings there seems to be an easy way and a hard way.

For the easy way, you initialize and run your application from within the rhino shell. You can do this directly from the shell, but that gets boring because you generally need quite a few lines to bootstrap your application. The solution here is to write a script, then call this script from rhino with the "-i" command line argument so the script runs and you get dropped back into the shell. See http://www.mozilla.org/rhino/scriptjava.html

The other approach is to start your application normally and then have some code in your application which embeds rhino.

For example, if your application is a servlet based webapp you can write a servlet which takes javascript code as an HTTP POST value and executes it passing in whatever variables/objects you want to expose. Naturally there are all sorts of security issues with this example, but that's a different issue. http://www.mozilla.org/rhino/tutorial.html

To get a proper interactive CLI interface from an embedded rhino setup is, I think, more difficult since you've got to figure out how to do the IO.

A good way to begin is to start up the shell, setting your classpath to include your application classes, and then start interacting with your own classes to get a feel for what you can do.

For command line experimenting it's worth while enabling readline to get tab completion and better history as per Norris Boyd's blog post: http://blog.norrisboyd.com/2009/03/rhino-17-r2-released.html

Hope that helps.
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to