如何让 Apple Java Extensions (com.apple.eawt) 在 JDK 7 及更高版本上工作?

2022-01-25 00:00:00 macos java java-native-interface cocoa

TL;DR:Apple 已放弃对 Java 的原生功能支持.特别是触摸板手势不再起作用.我编写了一个使用 JNI 完成这项工作的库.看看我下面的答案.

TL;DR: Apple has dropped native feature support in Java. Especially touchpad gestures are not working any longer. I wrote a library that does the job using JNI. Take a look at my answer below.

我正在寻找大约几个小时以使 Apple Java 扩展在 JDK 7 或 8 上运行.我一直在尝试所有我能想到的.互联网上所有关于此的线程都只是将此归咎于 JDK.我认为这应该是可以解决的,因为它在 JDK 6 中工作.为了清楚起见:我可以让它在 JDK 6 中工作,但我不想要这种遗留依赖项,因为不是每个将使用我的应用程序的人都有 JDK 6 或知道如何安装它,比方说.目标是制作一个可双击的 JAR 文件,该文件将在安装了每个 Java 版本(大于 JDK 6)的情况下使用 OS X 功能(菜单栏、手势、关于处理程序等)按预期运行.

I'm searching for about hours to make the Apple Java Extensions work on JDK 7 or 8. I have been trying all I can think of. All threads on the internet about this simply blame the JDK for this. I think this should be solvable, because it worked in JDK 6. For clarity: I can make it work in JDK 6, but I don't want this legacy dependency, because not everybody that will use my application has JDK 6 or knows how to install it, let's say. The goal is to make a double-clickable JAR file that will run as expected with the OS X features (menu bar, gestures, about handler, etc...) with every version of Java installed (greater than JDK 6).

推荐答案

自从 OS X El Capitan 的开发者预览版发布后,99% 的普通电脑用户都无法安装 Java 6,所以这不再是一种选择给我.我最终决定编写一个本地库,通过 JNI 通知 Java 有关手势的信息.该项目运行良好,托管在 GitHub 上.

Since the developer preview release of OS X El Capitan, it became impossible for 99% of average computer users to install Java 6, so this was no longer an option for me. I finally decided to write a native library that will inform Java about gestures through JNI. The project works great and is hosted on GitHub.

在这里看一下:https://github.com/mcourteaux/MultiTouch-Gestures-Java

相关文章