ic07b503
16 May 2010, 02:21 AM
Hi everybody!
I've a problem and I'm not able to solve it alone.
I want to invoke java methods of a self written java programm with javascript. I found something like a tutorial (http://stanislavvitvitskiy.blogspot.com/2009/04/calling-java-from-xul-applications.html), but it has not worked.
I put my class file in a jar file and when I want to load it in javascript i get an error.
I tried it this way:
var url = new java.net.URL('C:/java_js' + '/xultest.jar');
var cl = new java.net.URLClassLoader(url);
var aClass = java.lang.Class.forName("com.stan.XULDemo", true, cl);
var inst = aClass.newInstance();
// Calling 'sum' function from java
var a = inst.sum(2, 3);
alert(a); // Will alert '5'
Can anyone please help, and say to me what's wrong about it? Or does anyone have another aproach to call java methods with javascript?
cheers,
Martin
I've a problem and I'm not able to solve it alone.
I want to invoke java methods of a self written java programm with javascript. I found something like a tutorial (http://stanislavvitvitskiy.blogspot.com/2009/04/calling-java-from-xul-applications.html), but it has not worked.
I put my class file in a jar file and when I want to load it in javascript i get an error.
I tried it this way:
var url = new java.net.URL('C:/java_js' + '/xultest.jar');
var cl = new java.net.URLClassLoader(url);
var aClass = java.lang.Class.forName("com.stan.XULDemo", true, cl);
var inst = aClass.newInstance();
// Calling 'sum' function from java
var a = inst.sum(2, 3);
alert(a); // Will alert '5'
Can anyone please help, and say to me what's wrong about it? Or does anyone have another aproach to call java methods with javascript?
cheers,
Martin