Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bean Scripting Framework

Tags:

java

I'd like to use the Bean Scripting Framework to make some of my Java classes be available to users at my company who wish to write scripts + who may be familiar with Javascript or Python (via Jython) or Ruby (via JRuby).

I can't really find much tutorial documentation on how to get BSF working... what I would like to do is make a Java app that runs a shell, either in Javascript or Jython or JRuby, and exposes some Java classes of mine to the scripting language.

Any pointers? I've glanced through some of the docs at the BSF Resources page but I have a feeling I'm missing something obvious to get started.

(like there must be some shell already out there, complete w/ a rudimentary debugger...)

edit: To clarify -- I know how to run bsf.jar, it works fine. And I know how to run the Javascript shell with Rhino -- but that's specific to Javascript and has nothing to do with BSF. My question is, is there a language-agnostic shell that works with BSF?

like image 760
Jason S Avatar asked Feb 02 '26 00:02

Jason S


2 Answers

To use BSF you need bsf.jar and the library for your scripting language of choice on the classpath. To execute Javascript, no additional libraries are required.

To open an interactive Javascript console try:

java org.mozilla.javascript.tools.shell.Main
like image 53
groodt Avatar answered Feb 03 '26 14:02

groodt


Why do you need BSF?

Any JVM language can access Java classes directly. JRuby's way, Jython's. And any JVM language will have support for debugging somehow (an example here).

like image 24
HMM Avatar answered Feb 03 '26 14:02

HMM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!