How to compile InstantScript libraries

Printer-friendly versionSend to friendPDF version
Intermediate

This tutorial explains how to compile InstantScript in Streamezzo WorkBench Developer. The JDK is necessary to compile the rich media scenes. It is sometimes convenient to externalize InstantScript code in external libraries for reuse purpose or to avoid complexicity in RSP code. InstantScript libraries may be created using the Ant task that is embedded within Workbench Developer. Therefore we consider that the reader has a basic knowledge on Ant manipulation.

Reminder

An InstantScript library is defined with two files:

  • The expose file (.exp extension) defines the library API. It is used during the compilation phase.
  • The bin file (.bin extension) defines the binary part of the library, the code that will be executed at runtime.
The library contains classes that may be accessed from RSPs as long as they have been imported.

The expose files must be set as service InstantScript libraries to be used during the compilation phases. The libraries files must be set as service resources (terminal and/or server wether the InstantScript code will be used in terminal and/or server scenes).

Externalize script

Externalize script by building libraries is similar to the .jar file construction in the Java world. Here, the process is to write .java files by using the InstantScript API, and then to compile them with the Ant task.

We imagine here that you will not be satisfied by a simple text editor to code your classes. In order to code into your favorite Java IDE, the first step is to get the InstantScript API. Go into Workbench Developer, open/create a service and in the Service Desk view, deploy the "Libraries -> Script -> Standard library" branch. Then right click on the "Standard library" root and select "Export Java J2SE Library". You will get the InstantScriptAPI_J2SE.jar file.

You just have now to import the InstantScriptAPI_J2SE.jar file into the build path of your Java project, and you will take advantage of the auto-completion in you IDE.

The Ant task

Once your .java file ready, InstantScript libraries may be created using the stz.script.lib.package ant task that is embedded within Workbench Developer. Here is a sample code that makes advantage of this tool:

Here is the explanation of the properties used in this snippet of Ant code:

  • is.src.dir: the location of the .java sources, typically in a "src_is" folder in the root of your Workbench project.
  • script.dir: : the location where the .bin and .exp files will be generated, typically in a "script" folder in the root of your Workbench project.
  • exposePath: defines the library (expose files) that are required for compiling source files. Here we get the eventual other .exp files

Use your brand new library in your RSP

Three simple steps:

  1. Add your .exp file to your script libraries
  2. Add your .bin file to your resources
  3. Add the following instruction just once in your RSP code:

Share this