Java 不兼容的魔法值 1008813135
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2390733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Incompatible magic value 1008813135
提问by Warlax
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.
我正在编写一个 Java 小程序并将其嵌入到网页中。它曾经在不同的浏览器中运行 Mac 和 Windows,没有问题。我在 Mac 上使用 NetBeans 来构建小程序使用的 .jar 文件。
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:
出于某种原因,我决定在 Windows 的 NetBeans 上加载项目 - 从任何浏览器访问网页时,我开始在 Windows 机器上收到以下错误:
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.
担心一定是我决定在 Windows 上打开项目导致了这个错误——我试图从 Mac 的 NetBeans 构建——但错误仍然存在。
I started a while new project on the Mac and imported the existing source code: still same problem.
我在 Mac 上启动了一个新项目并导入了现有的源代码:仍然是同样的问题。
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.
我正在阅读有关此错误的一些信息,似乎预期的幻数是十六进制的 0xCAFEBABE,即十进制的 3405691582,而不是 1008813135。所以看起来 Mac 版本的 Java 不再生成此文件头了?锄头可以吗?我没有做任何更新或任何事情。
采纳答案by Pool
Yes, 0xCAFEBABE
is the usual first 4 bytes of a Java file.
是的,0xCAFEBABE
通常是 Java 文件的前 4 个字节。
1008813135is <!DO
in Latin encoding, which is, in all probability, the start of <!DOCTYPE...
.
1008813135是<!DO
拉丁语编码,很可能是<!DOCTYPE...
.
It is therefore likely the start of a 404 error
, or some other error page.
因此,它可能是404 error
或其他一些错误页面的开始。
回答by polygenelubricants
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
forum.sun.com - Java Applet 开发 - 类文件 MyApplet 中不兼容的魔法值 1008813135
Thanks God the problem is solved.
Its the Java cache, so the solution go to Java Control Panel, "General" tab, and under "Temporary Internet Files" click "Settings", then click "Delete Files". Try using the applet again.
感谢大神,问题解决了。
它是 Java 缓存,因此解决方案转到 Java 控制面板,“常规”选项卡,然后在“Internet 临时文件”下单击“设置”,然后单击“删除文件”。再次尝试使用小程序。
"Incompatible magic value 1008813135" Error?
The problem is now solved: I found out that the website host I was using didn't support .jar files at all. I mass-uploaded the files with my ftp program and didn't notice that it ignored the .jar files completely.
现在问题解决了:我发现我使用的网站主机根本不支持 .jar 文件。我用我的 ftp 程序批量上传了这些文件,并没有注意到它完全忽略了 .jar 文件。
Alright, so it was an apache configuration issue, removed this line from my httpd.conf file:
# DefaultType application/x-httpd-php
Fixed the issue.
好吧,这是一个 apache 配置问题,从我的 httpd.conf 文件中删除了这一行:
# DefaultType application/x-httpd-php
修复了问题。
回答by Inghard Gjovaag
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.
不兼容的幻数是 html 文件的前四个字节,其中包含一些错误消息,可能是找不到文件的消息。
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.
当我在小程序标签的代码库元素中没有考虑区分大小写时,我遇到了这种现象。事情在 Windows 上运行良好,但我使用的 Internet 服务器运行的是 UNIX,其中文件名区分大小写很重要。使代码和代码库元素中的所有文件和目录名称的大小写解决了问题。
回答by forest
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
如果您使用 Spring 安全或某种自定义 Servlet 过滤器,请确保存档或代码库位置在“permitAll”访问中。这对我来说是个问题
回答by naren_rana
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.
我遇到了同样的问题。在我的情况下,原因是Applet 使用的所有依赖库都没有签名,而且 Applet 也无法找到它们。
So i Have added all the dependent library along with main applet in jsp file like below :
所以我在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';
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.
希望这可能适用于您的情况。
回答by Shubh
I just clicked on maven->update project->include snapshot release in my spring boot and it worked.
我只是点击了 maven->update project->include snapshot release in my spring boot 就可以了。