简体   繁体   中英

Incompatible magic value 1013084704 when running java applet

I am getting the Incompatible magic value 1013084704 error when running the hello world applet:

import javax.swing.JApplet;
import javax.swing.SwingUtilities;
import javax.swing.JLabel;

public class Screenshot extends JApplet {
    //Called when this applet is loaded into the browser.
    public void init() {
        //Execute a job on the event-dispatching thread; creating this applet's GUI.
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    JLabel lbl = new JLabel("Hello World");
                    add(lbl);
                }
            });
        } catch (Exception e) {
            System.err.println("createGUI didn't complete successfully");
        }
    }
}

HTML CODE:

<applet code="Screenshot.class" archive="<?php echo URLgenerator::getScryptURL('screenshot.jar')?>" width="100px" height="100px"></applet>

The problem is something to do with the way that you are specifying the archive in the <applet ...> element.

Take a look at what the element really looks like when it reaches the web browser. Hint: use "View as source".

I expect that what is happening is that the URL for the archive is incorrect, and is resulting in the server delivering an error page. The browser is trying to interpret the HTML content of error page as if it was a JAR file or a class file, and finding that it doesn't have the required "magic number".

(Try viewing that number in hexadecimal, and then mapping the bytes to ASCII ...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM