Mac Java - 异常:java.lang.UnsupportedClassVersionError
一些 Mac 用户报告了此错误。我可以构建什么版本的小程序以便 Mac 用户可以使用它?
谢谢
Some mac users are reporting this error. What version can I build the applet so that Mac users can use it?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用交叉编译选项javac 的 a> 来编译与特定 Java 版本兼容的代码。
然后使用
deployJava.js
脚本(从 小程序上的信息页面链接)来检查用户拥有最低版本。正如其他人提到(/提到)的那样,Mac 可能支持各种 Java 版本。也许更相关的问题是这样的。
运行应用程序所需的最低 Java 版本是多少?
交叉编译选项(特别是使用
-bootclasspath
)应该明确回答这个问题。我最初没有提到
-bootclasspath
,因为您可能运行的是 1.7 SDK,现在当-source
/-target
时警告使用它被指定。使用该选项要求您有相关版本的rt.jar
(核心 J2SE 类)进行编译。它检查类、方法和内容是否正确。代码中的属性实际上存在于提供的 RT jar 中。因此,结果是,如果您有 1.6(或最新)编译器和相关目标版本的 JRE(用于
rt.jar
以及运行时测试) ),应该可以编译与任何版本兼容的代码。Use the cross-compilation options of
javac
to compile the code compatible for a particular version of Java.Then use the
deployJava.js
script (linked from the info. page on applets) to check the user has the minimum version.As others have mentioned (/alluded to), Macs might support a variety of Java versions. Perhaps a more relevant question is this.
What is the minimum Java version required to run the app.?
The cross-compilation options (especially using
-bootclasspath
) should answer that question definitively.I did not mention the
-bootclasspath
initially since you might have been running a 1.7 SDK that now warns to use it when-source
/-target
are specified. Using the option requires that you have anrt.jar
(the core J2SE classes) of the relevant version to compile against. It checks that the classes, methods & attributes in the code actually exist in the supplied RT jar.So the upshot is that if you have a 1.6 (or latest) compiler and a JRE of the relevant target version (for the
rt.jar
as well as run-time testing), it should be possible to compile code compatible for any version.检查 Mac 上的 JDK 或 JRE 版本。您正在使用旧版本的 JDK 或 JRE 来加载由比您的 JDK 或 JRE 版本更新的版本打包的 jar 文件。
Check out your JDK or JRE version on the Mac. You are using an older version of JDK or JRE to load a jar file that packaged by a newer version of JDK or JRE than yours.