D
David N. Welton
Hi,
In my applet, I have this:
public String callMethod(String methodName, String methodArg) throws
Exception {
try {
Class midletClass = midlet.getClass();
System.out.println("midlet class is " + midletClass);
Method []ms = midletClass.getMethods();
for (int i = 0; i < ms.length; i++ ) {
System.out.println("method: " + ms);
}
Method m = midletClass.getMethod(
methodName, new Class[] { String.class });
m.invoke(
midlet, new Object[] { methodArg });
return "OK";
} catch (Exception e) {
String failstr = "Problem calling method '" + methodName +
"' with argument '" + methodArg + "' \n" + e;
System.err.println(failstr);
e.printStackTrace();
return "FAIL: " + failstr;
}
}
However, it's not printing, or invoking this method, defined in a .jar
loaded by the first jar:
public void setScript(String s) { .... }
It gives a not found error when I try and invoke it, and when I try and
print it by accessing' midlets with getMethods, it doesn't show it.
The applet loads the .jar like so:
Class midletClass;
try {
midletClass = Class.forName(midletClassName);
} catch (ClassNotFoundException ex) {
System.out.println("Cannot find " + midletClassName + "
MIDlet class");
return;
}
try {
midlet = (MIDlet) midletClass.newInstance();
} catch (Exception ex) {
System.out.println("Cannot initialize " + midletClass + "
MIDlet class");
System.out.println(ex);
ex.printStackTrace();
return;
}
(Note that it's not actually running in a J2ME environment, despite the
'midlet' label.)
I'm out of ideas, more or less...
--
David N. Welton
- http://www.dedasys.com/davidw/
Linux, Open Source Consulting
- http://www.dedasys.com/
In my applet, I have this:
public String callMethod(String methodName, String methodArg) throws
Exception {
try {
Class midletClass = midlet.getClass();
System.out.println("midlet class is " + midletClass);
Method []ms = midletClass.getMethods();
for (int i = 0; i < ms.length; i++ ) {
System.out.println("method: " + ms);
}
Method m = midletClass.getMethod(
methodName, new Class[] { String.class });
m.invoke(
midlet, new Object[] { methodArg });
return "OK";
} catch (Exception e) {
String failstr = "Problem calling method '" + methodName +
"' with argument '" + methodArg + "' \n" + e;
System.err.println(failstr);
e.printStackTrace();
return "FAIL: " + failstr;
}
}
However, it's not printing, or invoking this method, defined in a .jar
loaded by the first jar:
public void setScript(String s) { .... }
It gives a not found error when I try and invoke it, and when I try and
print it by accessing' midlets with getMethods, it doesn't show it.
The applet loads the .jar like so:
Class midletClass;
try {
midletClass = Class.forName(midletClassName);
} catch (ClassNotFoundException ex) {
System.out.println("Cannot find " + midletClassName + "
MIDlet class");
return;
}
try {
midlet = (MIDlet) midletClass.newInstance();
} catch (Exception ex) {
System.out.println("Cannot initialize " + midletClass + "
MIDlet class");
System.out.println(ex);
ex.printStackTrace();
return;
}
(Note that it's not actually running in a J2ME environment, despite the
'midlet' label.)
I'm out of ideas, more or less...
--
David N. Welton
- http://www.dedasys.com/davidw/
Linux, Open Source Consulting
- http://www.dedasys.com/