Comunication with Marvin Sketch applet

User ca7f2ddaa5

08-07-2008 11:09:33

Hi,


I have a big problem. I want to make a HTML web page with two applets. The first one is "Marvin Sketch" applet represented by a signed jar file (no source code). Let’s call this “A”. The second one is mine. From witch I want to call some methods of A applet. Let’s call this “B”. For this I need to add A class to B’s classpath.





1. solution:


Make B in a nonamed package class too and I don’t need to import A. Because it is in the same package (nonamed) At compiling I have no problem. But in runtime a get a security error that say that jars with different sign are in the same package (nonamed package). Because the A’s class is in a nonamed packege and it is in a signed jar (tried to unsign but not working)





2. solution:


Make B in a named package class and import A. But this is not possible in JDK1.4. Only in 1.3. So I decided to make a wrapper class in a named package for A witch is compiled in JDK 1.3. But I can’t do this because I get a compilation error: “class file has wrong version 48.0, should be 47.0”





What can I do? Please help….

ChemAxon 7c2d26e5cf

10-07-2008 11:41:12

Dear Robert,


I assume that you approach to the problem from the wrong side.


Instead of insert Marvin applet classes into the CLASSPATH of your applet, use the reflection API to access methods of MarvinSketch applet.


To get the reference to the other applet on the same page, use this code sniplet:


Code:
String name = ...


Applet applet = getContext().getApplet(name);



Call the proper method with reflection API:


Code:
String methodname;


Class[] paramTypes;


Object[] args;


java.lang.reflect.Method method = applet.getClass().getMethod(methodname, paramTypes);


Object res = method.invoke(applet, args);





In this case, you do not have to give Marvin jars in the classpath of you applet by runtime.


By the way, Marvin sources are compiled with Java 1.4.2, that's why your JDK 1.3 does not accept Marvin classes.