简体   繁体   English

运行Java Applet时不兼容的魔术值1013084704

[英]Incompatible magic value 1013084704 when running java applet

I am getting the Incompatible magic value 1013084704 error when running the hello world applet: 运行hello world applet时出现不兼容的魔术值1013084704错误:

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: HTML代码:

<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. 问题与您在<applet ...>元素中指定档案的方式有关。

Take a look at what the element really looks like when it reaches the web browser. 看一下元素到达Web浏览器时的外观。 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. 我希望所发生的情况是存档的URL不正确,并导致服务器传递错误页面。 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". 浏览器试图将错误页面的HTML内容解释为是JAR文件还是类文件,并发现该页面没有所需的“幻数”。

(Try viewing that number in hexadecimal, and then mapping the bytes to ASCII ...) (尝试以十六进制查看该数字,然后将字节映射到ASCII ...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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