线程“main”中的 Tinyos 异常 java.lang.UnsupportedClassVersionError:.class 文件中的版本号错误
当我在 TinyOS 中使用 make 命令时,例如 make mica2 。 会出现以下问题:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
make: *** [exe0] Error 1
我重新安装了JAVA并添加了env变量,但没有用。 我使用 TinyOS 2.1 和 JAVA 1.5 u18。 谁能帮我?
通过安装 JDK 1.6 解决了问题。 尽管当我运行 tos-check-env 命令时,它会显示一条警告,告诉我它不是 JDK 1.4 或 1.5。 也许这是 TinyOS 中的一个错误。
When I use make command, like make mica2, in TinyOS. The following problem will occured:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
make: *** [exe0] Error 1
I reinstalled JAVA and add env variables, but it didn't work. I use TinyOS 2.1 and JAVA 1.5 u18. Can any one help me?
Problem solved by install JDK 1.6. Although when I run tos-check-env command, it shows me a warning that tell me its not JDK 1.4 or 1.5. Maybe it is a bug in TinyOS.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
使用 sudo update-alternatives --config java 并设置您可能想要使用的版本。
Use sudo update-alternatives --config java and set the version you may want to use.
UnsupportedClassVersionError 意味着您正在尝试在比其编译版本更旧的 JVM 版本上运行字节代码。您可以使用类文件查看器来检查源代码编译的 JDK 版本,并确保它与JAVA 1.5 u18。
an UnsupportedClassVersionError means you are trying to run byte code on an older version of the JVM than it was compiled in. You can use a class file viewer to check which version of the JDK the source code was compiled it and make sure it is compatible with JAVA 1.5 u18.
您收到的错误意味着正在运行的 Java 版本正在尝试加载使用不兼容的 Java 版本编译的类。
根据您提供的信息,不可能比这更具体地诊断问题 - 查看您正在使用的任何 Java 库以及它们所需的 Java 版本是什么。 如果您在这里找不到任何问题,您可能只需要清除一些在重新安装之前使用 Java 版本构建的缓存 *.class 文件。
最后,如果您安装了多个 JVM,请确保
make
使用您期望的那个。 您绝对有可能安装了 Java 1.5u18,但应用程序仍然从某处查找并使用 1.4 JVM。The error you're getting means that the version of Java that's running is trying to load a class that was compiled with an incompatible version of Java.
With the information you've provided it's not possible to diagnose the problem any more specifically than this - look at any Java libraries you're using and what their required Java versions are. If you can't find anything wrong here, you might just need to clean out some cached *.class files that were built with a version of Java before the reinstall.
Finally, if you have multiple JVMs installed be sure that
make
is using the one you expect. It's definitely possible for you to have installation Java 1.5u18 but for the application to still be finding and using a 1.4 JVM from somewhere.我今天遇到了同样的错误,我只是通过安装java版本1.6和jre6并将Java 1.6版本设置为默认版本来解决它。
我之前还安装了 java 1.5,因为 tos-check-env 希望我安装 java 1.4 或 java 1.5 版本。
我还将 java 1.5 和 1.6 版本都包含到我的类路径中,并在
/opt/tinyos-2.1.0/apps/Blink
目录中再次运行make micaz
,它工作了。I got the same error today, and I simply solved it by installing java version 1.6 and jre6, and by making Java 1.6 version as the default version.
I also had java 1.5 installed earlier, as tos-check-env wanted me to have either java 1.4 or java 1.5 versions installed.
I also included both the java 1.5 and 1.6 versions to my classpath and ran
make micaz
again in the/opt/tinyos-2.1.0/apps/Blink
directory and it worked.通常会有一条消息,例如
异常消息的第一行。 但是,您有
那么也许您的类文件已损坏?
Normally there would be a message such as
in the first line of the exception message. However, you got
So maybe your class file is corrupted?