不兼容的魔法值1008813135
我正在编写一个 Java 小程序并将其嵌入到网页中。 它曾经在不同的浏览器中运行 Mac 和 Windows 没有问题。 我在 Mac 上使用 NetBeans 来构建小程序使用的 .jar 文件。
由于某种原因,我决定在 Windows 的 NetBeans 上加载该项目 - 当从任何浏览器访问网页时,我开始在 Windows 计算机上收到以下错误:
java.lang.ClassFormatError: Incompatible magic value 1008813135 in class file
担心这一定是我决定在 Windows 上打开该项目这导致了这个错误 - 我尝试从 Mac 的 NetBeans 构建 - 但错误仍然存在。
我在 Mac 上启动了一个新项目并导入了现有的源代码:仍然是同样的问题。
我正在阅读有关此错误的内容,似乎预期的幻数是十六进制的 0xCAFEBABE,十进制的 3405691582,而不是 1008813135。所以看起来 Mac 版本的 Java 不再生成此文件头?锄头可以吗?我没有做任何更新或任何事情。
I am writing a Java applet and embedding it in a web page.
It used to run Mac and Windows in different browsers without problem.
I was using NetBeans on the Mac to build the .jar file the applet used.
For some reason or another I decided to load the project on the Windows' NetBeans - I started getting the following error on the Windows machine when accessing the web page from any browser:
java.lang.ClassFormatError: Incompatible magic value 1008813135 in class file
Fearing that it must have been my decision to open the project on Windows that caused this error - I tried to build from the Mac's NetBeans - but the error persisted.
I started a while new project on the Mac and imported the existing source code: still same problem.
I was doing some reading about this error and it seems that the magic number expected is 0xCAFEBABE in hex which is 3405691582 in decimal, not 1008813135. So it looks like the Mac version of Java doesn't produce this file header any more? Hoe can that be? I didn't do any updates or anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
是的,
0xCAFEBABE
是 Java 文件通常的前 4 个字节。1008813135 是拉丁编码中的
,很可能是
的开头。
因此,它可能是
404 错误
或其他错误页面的开始。Yes,
0xCAFEBABE
is the usual first 4 bytes of a Java file.1008813135 is
<!DO
in Latin encoding, which is, in all probability, the start of<!DOCTYPE...
.It is therefore likely the start of a
404 error
, or some other error page.我没有遇到过这个问题,但是谷歌搜索这个错误会产生几种可能的解决方案:
论坛。 sun.com - Java Applet 开发 - 类文件 MyApplet 中不兼容的魔法值 1008813135
“不兼容的魔法值 1008813135”错误?
java 初始化错误
I have not experienced this problem, but Googling this error yields several possible solutions:
forum.sun.com - Java Applet Development - Incompatible magic value 1008813135 in class file MyApplet
"Incompatible magic value 1008813135" Error?
Errors on java initialization
如果您使用 Spring 安全性或某种自定义 Servlet 过滤器,请确保存档或代码库位置位于“permitAll”访问权限中。这对我来说是个问题
If you are using Spring security or some sort of custom Servlet Filters, make sure, that the archive or codebase location is in "permitAll" access. This was to problem in my case
我遇到了同样的问题。在我的例子中,原因是Applet 使用的所有依赖库都未签名,并且 applet 无法找到它们。
所以我在 jsp 文件中添加了所有依赖库以及主小程序,如下所示:
app.archive = '/esense/resources/lib/Applet.jar, /esense/resources/lib/jasypt-1.7.jar, /esense/resources/lib/mysql-connector-java-5.1.30.jar, /esense/resources/lib/runtime-api-1.0.jar';
我还签署了所有 jar。
希望这适用于您的情况。
I was facing the same problem.The reason in my case was all dependency library that Applet uses was not signed and also applet not able to locate them.
So i Have added all the dependent library along with main applet in jsp file like below :
app.archive = '/esense/resources/lib/Applet.jar, /esense/resources/lib/jasypt-1.7.jar, /esense/resources/lib/mysql-connector-java-5.1.30.jar, /esense/resources/lib/runtime-api-1.0.jar';
I have also signed all the jar.
Hope this may work in your case.
不兼容的幻数是 html 文件的前四个字节,其中包含一些错误消息,可能是找不到该文件的消息。
当我在小程序标签的代码库元素中没有考虑区分大小写时,我遇到了这种现象。在 Windows 上一切正常,但我使用的互联网服务器运行的是 UNIX,其中文件名区分大小写很重要。在代码和代码库元素中使用所有文件和目录名的大小写解决了这个问题。
The incompatible magic number is the first four bytes of a html file that has some error message in it, probably a message that the file isn't found.
I encountered this phenomenon when I didn't take case sensitivity into account in the codebase element of the applet tag. Things worked well on Windows, but the internet server I was using was running UNIX where filename case sensitivity is important. Making the case of all file and directory names in the code and codebase elements solved the problem.
我只是单击了 maven-> 更新项目-> 在我的 Spring Boot 中包含快照版本,它就工作了。
I just clicked on maven->update project->include snapshot release in my spring boot and it worked.
我在使用 URLClassLoader 从 URL 加载类时收到此错误。
我给它的 URL 是 HTTP,在服务器上我有一个 HTTP 到 HTTPS 的重定向,在类加载时我会收到此错误。
我解决这个问题的方法是,我首先连接到该 URL,并检查我是否被重定向到 HTTPS,如果是,我只需将我调用的 URL 更改为 HTTPS。
I was getting this error while using URLClassLoader to load a class from an URL.
The URL i gave it was HTTP and on the server I had a HTTP to HTTPS redirect, and at class loading i would get this error.
How i fixed it is i first connect to the URL and check if i'm being redirected to HTTPS, if I am, i just change the URL i call to be HTTPS.