10

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.


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

Martijn Courteaux
  • 67,591
  • 47
  • 198
  • 287

4 Answers4

5

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.

Take a look at it here: https://github.com/mcourteaux/MultiTouch-Gestures-Java

Martijn Courteaux
  • 67,591
  • 47
  • 198
  • 287
  • Agreed. But the lib suggests copying a .so file to /. Some users do not have the permissions to do that. Can your solution be bundled as a jar or it requires manual fiddling with the system for every installation? – Radu Simionescu Apr 13 '16 at 13:41
  • You *could* try to use File.createTempFile instead and in combination with this hack: https://stackoverflow.com/questions/15409223/adding-new-paths-for-native-libraries-at-runtime-in-java But this seems not something you want to do. However, I believe that JavaFX has support for multitouch input handling cross-platform. – Martijn Courteaux Apr 14 '16 at 12:18
2

I just happened to run across your question and noted that it has not been answered yet. I have a Java program that I have been developing on the Mac, and noted that when I ran it under Java 7, the menu bar, Preferences, Quit and About all worked fine using rt. jar in the program's libraries folder and using a MacAppMenuHandler class that I wrote to provide functionality for those items.

However, when I switched to Java 8, they no longer worked. I'm not sure what the issue is though reading other web sites today suggest a "permissions" issue in Java 8 regarding these files.

However, I solved the problem by copying the rt. jar from Java 7 into the program's libraries, and it has continued to work for me while continuing to develop under Java 8.

I suggest this as one possible solution to the problem.

Hope this helps.

Ken
  • 61
  • 3
  • Wow, this looks amazing news. What version of Java 7 do you have? Which developer? Oracle? Some open source alternative? – Martijn Courteaux Jul 30 '14 at 10:35
  • 1
    I am running Java 7 and Java 8 standard issue from Oracle, not from an open source or other alternative Java. the rt. jar is: Java 1.7_051 – Ken Jul 30 '14 at 13:10
  • Did you try if the Touchpad Gestures work with Java 7 as well? It seems that indeed, menu bar works and the Preferences thing as well. But gestures don't. However, I had to use a command line argument to make the menu bar work. – Martijn Courteaux Jul 30 '14 at 13:43
  • Oh god.... I always did this: `if (System.getProperty("mjr.version") != null)` and then I did the OS X tweaks. Just removing the condition fixed it... This is an incompatibility with Java 7. Now, only the gestures don't work. – Martijn Courteaux Jul 30 '14 at 14:33
  • I'm still not sure why one cannot access the rt. jar OS X components for Java 8 and have everything appear as expected for OS X. I haven't seen any additional discussion about it. – Ken Jul 30 '14 at 15:02
2

Go on your project Properties and select the Java Build Path Libraries, your JRE System Library should have an Access rules field like the one displayed in the image

enter image description here

Hit the Edit button and add an access rule to allow access to the com.apple.eawt package.

enter image description here

u09
  • 449
  • 1
  • 3
  • 11
0

I had the same problem with "pinch to zoom" - it works in java 6 but not 7 or 8. I came across this bug in the jdk which seems to be responsible. It says it is fixed in Java 9.

Amber
  • 2,413
  • 1
  • 15
  • 20