I have a Java applet that has an int array. I want to copy this array over to a JavaScript array. Simply calling a Java function from JavaScript that returns this array results in null exception and accessing the array element by element from JavaScript leads to browser crashes. What is the correct way to handle this? Perhaps JSObject?
2 Answers
Try this:
<applet code="Applet.class" name="Applet" />
<script>var f = document.Applet.foobar();</script>
And
class Applet extends java.applet.Applet {
public void init() {}
public int[] foobar(){
return new int[]{1,2,3};
}
}
You could use netscape JSObject to interact with JavaScript from Java Applet. Have a look at the below tutorial. It might be useful for you.
2 Comments
Aravind
Thanks, but simply calling a function that returns the int array turned out to be easier.
Avinash K.P
Yes. it's simpler indeed :)
applettagint).