Subj : Re: my next newbie question To : Ronald Kent Gibson From : Igor Bukanov Date : Thu Mar 04 2004 04:31 pm Ronald Kent Gibson wrote: > ok so now I am playing with the idea of generating the javascript class and > then accessing it from java so I wrote this program. > > function getValue() > { > x = 1; > y = 2; > z = x + y; > return z; > } > > But when I decompile it there is no getValue method. > > hmm. so How would I access this function? JavaScript functions are not compiled to correspondingly named methods of byte code. To access the function you have to use -extends or -implements options to http://www.mozilla.org/rhino/jsc.html to make the resulting script file to extend the given interface and then in you Java program cast a script instance to that class or interface. Another option is to take advantage of the fact that the main class file for the script implements org.mozilla.javascript.Script interface. Then you create an instance of the class, call Script.exec(cx, scope) which would define all script functions in the supplied scope so you can use later: ScriptableObject.callMethod(scope, "getValue", Context.emptyArgs) to call the method. Regards, Igor .