Subj : [Rhino] Exposing a ScriptableObject to JavaScripts To : netscape.public.mozilla.jseng From : google@visualxs.com (giggler) Date : Thu Apr 03 2003 07:01 pm js file ======= 1. defineClass("MyTask"); 2. var task = new MyTask(); 3. task.doSomething(); 4. out.println('Hello, World!'); MyTask class ============ public class MyTask extends ScriptableObject { ... public void jsFunction_doSomething() throws JavaScriptException { //doSomething } } My launcher class ================= 1. Context jsContext = Context.enter(); 2. Scriptable scope = new Global(jsContext); 3. Scriptable scope1 = Context.toObject( System.out, scope); 4. scope.put("out", scope, scope1); 5. jsContext.evaluateReader( scope, scriptFile, _scriptFilename, 1, null); This works fine for me, however MyTask is an object I want my script creators to have access to without defining the class first. How can I expose this object so it is always available to them? I have tried the following without success. I get the "TypeError: undefined is not a function." error. 4a. Scriptable scope2 = Context.toObject( new MyTask(), scope); 4b. scope.put("task", scope, scope2); I fail to see what makes MyTask any different than System.out besides the fact that MyTask is instanced and System.out is a static variable? .