Hosted by Three Crickets

Scalable Alternative to JSR-223

Scripturian logo: kitten in shawl


Next chapter: Executing Documents
Or, go back to the manual's table of contents

Part 1: Bootstrapping Applications

Scripturian comes with a ready-to-rumble execution environment that lets you execute file-based documents immediately, without writing any Java code. (The rest of the tutorial will show you how to execute documents programmatically from Java.)

First, create your entry point code. For this example, we'll use JavaScript, and create a file named "start.js":

print('Hello, world, from Scripturian!');

To run this code, make sure the Scripturian jar, and required language engine jars, are on your JVM classpath. Then, from the command line run:

java com.threecrickets.scripturian.Scripturian /start/ 

Ta da! You've just used JavaScript on the JVM without writing a single line of Java code. Moreover, you can easily swap the language implementation: make a "start.rb" file instead of a "start.js" file to use Ruby instead of JavaScript.

Your entire application can then proceed from that initial entry point without ever requiring Java.

API Services

Scripturian exposes a few API services to your executables: executable, document, and application. Click the links to see the API documentation for each. An example of usage:

application.globals.put('name', 'world');
print('Hello, ' + application.globals.get('name') + ', from Scripturian!');

Command Line Arguments

The defaults may be good enough, but you can also configure your bootstrapping:

Special Note for Jython

To use Jython, you must specify the "python.home" JVM property. Jython will look for its "Lib" directory underneath the home directory:

java -Dpython.home=~/jython/ com.threecrickets.scripturian.Scripturian /start/ 

Changing the Cache Location

By default, Scripturian will cache prepared (compiled) documents under "scripturian/cache" relative to the current directory, but you can set this explicitly via the "scripturian.cache" JVM property:

java -Dscripturian.cache=/tmp/scripturian/ com.threecrickets.scripturian.Scripturian /start/ 

Note that you may delete these cached file at any time, and Scripturian will regenerate them if necessary.

Next chapter: Executing Documents
Or, go back to the manual's table of contents