Subj : Re: return values with embedded rhino To : Patrick From : Igor Bukanov Date : Tue Jul 29 2003 01:20 pm Patrick wrote: > with this > "meme = youyou.getMsg();" > I get: > undefined > > with this > "meme = youyou;" > I get: > adapter0@379 > > How do I get the String? > > ############################## > function testRhino() { > /* > patrick testing > */ > var meme = ""; > var youyou = ""; > youyou = new JavaAdapter(java.ServerMsgs); > meme = youyou.getMsg(); > if (meme == "") { > meme = "Did not work bob"; > } > return meme; > } > ############################## > public class ServerMsgs{ > public String getMsg() { > return "got Message"; > } > } > I can see few problems here: 1. You have to use Packages.ServerMsgs to access ServerMsgs. The notation java.xxx is just a shorthand for Packages.java.xxx and is only available for packages under java. hierarchy. 2. You did not specify which JS objects extends Java class functionality when you call JavaAdapter. When I replaced the line youyou = new JavaAdapter(java.ServerMsgs); by var javaExtension = {}; youyou = new JavaAdapter(Packages.ServerMsgs, javaExtension); then it worked. It seems for me that in your example you do not intend to subclass ServerMsgs. But to access the class you do not need any JavaAdapter functionality as constructing/calling ServerMsgs is supported by general Java scripting support: var youyou = new Packages.ServerMsgs(); meme = youyou.getMsg(); works as well and is much faster. Regards, Igor .