Hirdetés

Keresés

Új hozzászólás Aktív témák

  • ArchElf
    addikt

    Hi!

    szeretnek irni egy java applet-et, de a html-be agyazasnal problemakba utkoztem
    a cel az lenne, hogy az applet funkcioit javascript-en keresztul meg tudjam hivni, ami mukodik is, viszont ekkor az alkalmazas elszall exception-nel, mondvan nem talal bizonyos class-okat
    ami miatt az egeszet nem ertem, az az, hogy az applet eclipse alol inditva az appletviewer-rel tokeletesen mukodik

    az altalam irt java kod:
    package hu.jmk.ipv6;
    import java.applet.Applet;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.net.InetAddress;
    import java.net.UnknownHostException;

    import org.xbill.DNS.*;

    public class IPv6Indicator extends Applet {
    static final long serialVersionUID = 0x1;

    public void paint(Graphics g) {
    setBackground(Color.blue);
    g.drawString("[" + getAddress("jmk.hu") + "]", 10, 20);
    g.drawString("6!", getWidth() / 2, getHeight() / 2);
    }

    public String getAddress(String hostName) {
    String hostAddress = null;

    try {
    InetAddress inetAddress = Address.getByName(hostName);
    hostAddress = inetAddress.toString();
    } catch (UnknownHostException e) {
    hostAddress = "exception";
    }

    return hostAddress;
    }
    }

    a hivatkozott dnsjava csomag

    a html, amibe beagyazni kivanom:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
    <head>
    <script src="scripts/index.js" type="text/javascript"></script>
    <title>IPv6 indicator</title>
    </head>
    <body>
    <div>
    <object id="dnsapplet" classid="java:hu.jmk.ipv6.IPv6Indicator.class" archive="IPv6Indicator.jar" type="application/x-java-applet" mayscript="true" scriptable="true" height="100" width="100">

    <param name="archive" value="IPv6Indicator.jar"/>
    <param name="codebase" value="applets"/>
    <param name="code" value="hu.jmk.ipv6.IPv6Indicator"/>
    <param name="mayscript" value="true"/>
    <param name="scriptable" value="true"/>
    </object>
    <!-- <applet id="dnsapplet" code="DNSClass" codeBase="applets" height="10" width="10"/> -->
    </div>
    </body>

    </html>

    a beagyazott jar file

    a javascript, ami a fuggvenyhivast vegezne:
    try {
    var applet = document.getElementById( "dnsapplet" );
    alert( "applet: " + applet );
    alert( "isActive: " + applet.isActive() );
    //alert( "init: " + applet.init() );
    //alert( "test: " + applet.getAddress( "jmk.hu" ) );
    //alert( "echo: " + applet.echo( "Some text for echo testing" ) );
    //alert( "myfunction: " + applet.myfunction() );
    alert( "getARecord: " + applet.getAddress( "jmk.hu" ) );
    } catch ( e ) {
    alert( e.toString() );
    }

    ebben kicsit sok a "szemet", mert opera extension-nek keszulne, de az ahhoz tartozo kodok ki vannak kommentelve

    az exception (ami java console-ban lathato): Exception in thread "AWT-EventQueue-2" java.lang.NoClassDefFoundError: Could not initialize class org.xbill.DNS.Lookup

    kerdesem az lenne, hogy mi okozza a problemat, mit rontok el, illetve hol

    Udv: VladimirR

    Szerintem (találtam :D)
    Unsigned applets cannot perform the following operations:

    They cannot access client resources such as the local filesystem, executable files, system clipboard, and printers.
    They cannot connect to or retrieve resources from any third party server (any server other than the server it originated from).
    They cannot load native libraries.
    They cannot change the SecurityManager.
    They cannot create a ClassLoader.
    They cannot read certain system properties. See System Properties for a list of forbidden system properties.

    És még:
    Note:

    JavaScript code is treated like unsigned code.
    When a signed applet is accessed from JavaScript code
    in an HTML page, the applet is executed within the
    security sandbox. This implies that the signed applet
    essentially behaves likes an unsigned applet.

    AE

Új hozzászólás Aktív témák