@@ -0,0 +1,2011 @@
+/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-%0A *%0A * The contents of this file are subject to the Netscape Public License%0A * Version 1.0 (the %22NPL%22); you may not use this file except in%0A * compliance with the NPL.  You may obtain a copy of the NPL at%0A * http://www.mozilla.org/NPL/%0A *%0A * Software distributed under the NPL is distributed on an %22AS IS%22 basis,%0A * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL%0A * for the specific language governing rights and limitations under the%0A * NPL.%0A *%0A * The Initial Developer of this code under the NPL is Netscape%0A * Communications Corporation.  Portions created by Netscape are%0A * Copyright (C) 1999 Netscape Communications Corporation.  All Rights%0A * Reserved.%0A */%0A%0Aimport org.mozilla.javascript.*;%0A%0A/**%0A * RunScript: simplest example of controlling execution of Rhino.%0A * %0A * Collects its arguments from the command line, executes the %0A * script, and prints the result.%0A * %0A * @author Norris Boyd%0A */%0Apublic class RunScript %7B%0A    public static void main(String args%5B%5D) %0A        throws JavaScriptException %0A    %7B%0A        // Creates and enters a Context. The Context stores information%0A        // about the execution environment of a script.%0A        Context cx = Context.enter();%0A        %0A        // Initialize the standard objects (Object, Function, etc.)%0A        // This must be done before scripts can be executed. Returns%0A        // a scope object that we use in later calls.%0A        Scriptable scope = cx.initStandardObjects(null);%0A        %0A        // Collect the arguments into a single string.%0A        String s = %22%22;%0A        for (int i=0; i %3C args.length; i++)%0A            s += args%5Bi%5D;%0A        %0A        // Now evaluate the string we've colected.%0A        Object result = cx.evaluateString(scope, s, %22%3Ccmd%3E%22, 1, null);%0A        %0A        // Convert the result to a string and print it.%0A        System.err.println(cx.toString(result));%0A        %0A        // Exit from the context.%0A        Context.exit();%0A    %7D%0A%7D%0A%0A

Add new example.