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.)
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/
Your entire application can then proceed from that initial entry point without ever requiring Java.
application.globals.put('name', 'world'); print('Hello, ' + application.globals.get('name') + ', from Scripturian!'); document.execute('/server/');
Command Line Arguments
The defaults may be good enough, but you can also configure your bootstrapping:
- If you do not specify the document name, Scripturian will try to run the document specified by --default-document-name (see below)
- --base-path=.: Use this to change the base path in which documents will be looked for, the default is the current directory.
- --preferred-extension=js: When filename extensions aren't specified, this extension will be preferred.
- --prepare=true: The default it true, but you can set "prepare" to false to force Scripturian not to compile your source code. Not all languages support this, but if they do, this will cause them to run in "interpreted" mode, which may be slower, but may have faster startup time.
- --default-document-name=default: If a document name points to a directory instead of a file, then Scripturian will look in that directory for a file with this name.
- --document-service-name=document and --application-service-name=application: Use these to change the names of these two API services (useful in case there is conflict with other APIs).
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.