add new function in javascript
"george.tovrea" <[email protected]> Thu, 25 Feb 2010 21:18:55 +0800
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Message-ID | <[email protected]> |
Hello to every one!
I want to call my java code through javascript and these code as follows :
// We are in the global Firefox script scope, so only use our own unique
global names; best to have at most one
// global in the global namespace
var java_demo = {
LiveConnect : {},
onMenuItemCommand : function () {
Components.utils['import']('resource://javaDemo/LiveConnectUtils.js',
this.LiveConnect);
var jars = ['URLSetPolicy.jar', 'Test.jar','ServerTest.jar'];
var [loader,urls] = this.LiveConnect.initWithPrivs(java,
'[email protected]', jars);
var aClass = java.lang.Class.forName('Test', true, loader);
var aStaticMethod = aClass.getMethod('getGreetings', []); // Fails
here
var greeting = aStaticMethod.invoke(null, []);
alert(greeting);
}
};
var myClass = loader.loadClass('ServerTest'); //Load once
var myObj = myClass.newInstance();
var binval = myObj.StartServer('Server_IP');
alert(binval);
first one function is active when user click then menuItem
(onMenuItemCommand : function) and ServerTest is load once when user open
firefox
but myClass looks like didn't active my ServerTest code .
anybody knows what's happening !
any idea ?
Thanks!
George