Mac Java - 异常:java.lang.UnsupportedClassVersionError

发布于 2024-12-26 11:39:17 字数 62 浏览 1 评论 0原文

一些 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟火散人牵绊 2025-01-02 11:39:17

使用交叉编译选项javac 的 a> 来编译与特定 Java 版本兼容的代码。

然后使用 deployJava.js 脚本(从 小程序上的信息页面链接)来检查用户拥有最低版本。

我可以构建什么版本的小程序以便 Mac 用户可以使用它?

正如其他人提到(/提到)的那样,Mac 可能支持各种 Java 版本。也许更相关的问题是这样的。

运行应用程序所需的最低 Java 版本是多少?

我相信 1.4 也许 1.3 是最低要求。我一直使用 1.6 来构建它。

交叉编译选项(特别是使用 -bootclasspath)应该明确回答这个问题。

我最初没有提到 -bootclasspath ,因为您可能运行的是 1.7 SDK,现在当 -source/-target 时警告使用它被指定。使用该选项要求您有相关版本的 rt.jar(核心 J2SE 类)进行编译。它检查类、方法和内容是否正确。代码中的属性实际上存在于提供的 RT jar 中。

因此,结果是,如果您有 1.6(或最新)编译器和相关目标版本的 JRE(用于 rt.jar 以及运行时测试) ),应该可以编译与任何版本兼容的代码。

如果我下载 1.4 并使用它进行构建,它应该适用于几乎所有人?

  • 它不需要 JDK,只需要 JRE 和正确的交叉编译选项。
  • 将代码交付给“每个人”是不切实际的。有些人(或控制他们使用的 PC 的人)选择不安装 Java,如果它是标准的,则将其禁用。

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.

What version can I build the applet so that Mac users can use it?

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.?

I believe 1.4 maybe 1.3 is the minimum required. I've been using 1.6 to build it tho.

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 an rt.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.

If I download 1.4 and build with that, it should work for pretty much everyone?

  • It does not require a JDK, just a JRE and the right cross-compilation options.
  • It is impractical to deliver code to 'everyone'. Some people (or whoever controls the PC they use) choose not to install Java, to disable it if it comes standard.
别理我 2025-01-02 11:39:17

检查 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文