开发者

Java applet crashing chrome java on ubuntu when calling javascript function

开发者 https://www.devze.com 2023-02-22 22:05 出处:网络
Working with chrome on ubuntu, have a basic java applet and javascript interaction.The javascript to java goes fine, but when I try having the java fire a javascript method, the chrome java plugin cra

Working with chrome on ubuntu, have a basic java applet and javascript interaction. The javascript to java goes fine, but when I try having the java fire a javascript method, the chrome java plugin crashes. This all works fine in Fire Fox.

The Error:

The following plug-in has crashed: icedTea NPR Web Browser Plugin (using IcedTea6 1.9.7 (6b20-1.9.7-0ubuntu1~10.04.1))

The HTML:

<object height='300' id='thisap开发者_StackOverflowpletawesome' name='thisappletawesome'type='application/x-java-applet' width='550'>
    <param name='classid' value='java:JSHelloWorld.class'> 
    <param name='codebase' value='/java/'> 
</object> 

The Javascript:

function updateWebPage(){
    alert("java is touching me");
    document.thisappletawesome.setText("hihihi")
}

The Java:

import java.applet.*;
import java.awt.*;
import netscape.javascript.*;
import javax.swing.*;

public class JSHelloWorld extends JApplet {
JTextArea txt = new JTextArea(100,100);

public void init(){
    JSObject jso = JSObject.getWindow(this);
    try {
        jso.call("updateWebPage", new String[] {"Hihi"});
    }
    catch (Exception ex) {
       ex.printStackTrace();
    }
}

public JSHelloWorld() {
    txt.setText("Hello World");
    getContentPane().add(txt);
}

public void setText(String s)
{
    txt.setText(s);
}    


The problem looks like it was with OpenJDK.

sudo aptitude remove icedtea6-plugin
sudo aptitude install sun-java6-plugin

Fixed the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号