Bean Scripting Framework

Bean Scripting Framework (BSF) is a set of Java classes which provides scripting language support within Java applications, and access to Java objects and methods from scripting languages. BSF allows one to write JSPs in languages other than Java while providing access to the Java class library. In addition, BSF permits any Java application to be implemented in part (or dynamically extended) by a language that is embedded within it. This is achieved by providing an API that permits calling scripting language engines from within Java, as well as an object registry that exposes Java objects to these scripting language engines.

There are now two different versions of Apache BSF. These have different APIs.
The original version of BSF is represented by the BSF 2.x releases (current version 2.4), and uses an API which was originally developed at IBM.
The new version of Apache BSF is represent by the 3.x releases. The 3.x version uses the API defined as part of JSR-223 (javax.script), which is included in Java 1.6 onwards. However BSF 3.x will run on Java 1.4+, allowing access to JSR-223 scripting for Java 1.4 and Java 1.5. Apache BSF 3.x is also useful for Java 1.6 as it contains a command-line utility for testing JSR-223 scripts as well as some utility classes for working with XML.

Supported Languages - 2.x

BSF 2.x supports several scripting languages currently:

In addition, the following languages are supported with their own BSF engines:

Information on where to obtain scripting languages for use with BSF is available on the Related Projects page.

Documentation (2.x)

You can view the documentation for BSF 2.4.

Documentation and examples are included in the source and binary distributions.

Documentation (3.x)

The following references describe the standard API (javax.script) which is implemented by BSF 3.x:

Apache BSF 3.x includes an implementation of JSR-223 (javax.script) and runs on Java 1.4 and Java 1.5. (Java 1.6 includes javax.script as standard.) Note that although the implementation follows the JSR-223 specification, it has not been tested against the JSR-223 TCK. Apache BSF 3.x can therefore not strictly be described as a compatible implementation of JSR-223, however it is believed to be complete.

Apache BSF 3.x also includes some utility classes for working with XML. These can be used with any used with any implementation of the javax.scripting package, including the one in Java 1.6+.

There is also a command-line utility which can be used to run scripts in any language engine which supports JSR-223.

Note that Apache BSF does not contain any language engines; these have to be downloaded separately. Version 3.0 was shipped with a set of engine factories, however this is no longer present in later versions of BSF. This is because many languages are now provided with their own factories.
Also, having all the factories in a single jar can cause problems at run-time. If other jars contain factories that implement a different version of the same language it may be difficult or impossible to choose which version is loaded.
If the language implementation is not present, the factory class may fail to load; with some implementations of javax.script (e.g. Sun Java 1.6) this may prevent any factories from loading.

An example language which includes the necessary engine factory is: Apache Jexl 2.0 (requires Java 1.5). Some other scripting languages also come with their own factories already included. For example Groovy and JRuby.

Many other languages are supported by the 3rd party engine factories available at This provides a combined archive from which the appropriate jar for the language can be extracted.