leap motion java sdk - max closes when running mxj

    Aug 24 2013 | 10:48 am
    Hello. I'm trying to write a Java External that can work with the Leap Motion device.
    in max.java.config.txt I configured the following:
    max.system.jar.dir /Volumes/2g-storage/projects/java-projects/jar/
    this points to
    LeapJava.jar libLeap.dylib libLeapJava.dylib
    and I configured
    max.dynamic.class.dir /Volumes/2g-storage/projects/java-projects/leapmotion/piano/bin/
    which points to the compiled classes
    now when I fire up max and try 'mxj MaxLeapMotion' the program just quits. it doesn't show any segmentation fault error to report, it just closes.
    about support information: { "version" : "Version 6.1.3 (ac9dafd)", "platform" : "mac", "arch" : "x64", "osversion" : "Mac OS X Version 10.8.4 x86_64", "samplerate" : 44100, "iovs" : 64, "sigvs" : 64, "scheduler_in_audio_interrupt" : "off", "audio_drivername" : "Live", "audio_driver_subname" : "", "eventinterval" : 2, "overdrive" : "off", "mixerparallel" : "off", "mixercrossfade" : 0, "mixerlatency" : 30.0, "mixerramptime" : 10.0 }
    using max for live with ableton 9.0.5 and max 6.1.3
    the problem occurs when I try to create a new leap motion Listener
    even if the Listener class is empty:
    import com.leapmotion.leap.Listener
    public class TestListener extends Listener {
    when I try to instance the class the results are the same, max just closes right away with no pre-warning of any kind.
    import com.cycling74.max.DataTypes;
    import com.cycling74.max.MaxObject;
    import com.leapmotion.leap.Controller;
    public class MaxLeapMotion extends MaxObject {
    public void bang() {
    outlet(0, "congradulations!");
    public MaxLeapMotion() {
    declareOutlets(new int[]{DataTypes.LIST});
    TestListener listener = new TestListener(); //new SampleListener(null);
    } --------------------------
    any ideas how to debug this issue further ?

    • Aug 24 2013 | 5:45 pm
      Anything in the OS X Console?
    • Aug 24 2013 | 8:30 pm
    • Aug 26 2013 | 10:21 am
      Next step is to attach a Java debugger such as Eclipse and step through the code. I suspect something somewhere is calling System.exit(0).
    • Nov 05 2013 | 9:22 am
      Hello, are there any developments with the java external? In case you continue the work, will it work in windows as well?
    • Nov 05 2013 | 2:56 pm
      I actually wrote a mxj for Leap SDK myself. The problem is, that the Leap Java SDK includes a native dynamic library (dll on Win, dylib on Mac), to communicate with the Leap hardware. So to use this on a platform-agnostic java virtual machine, Java uses a mechanism called JNI (Java Native Interface). If the Java VM does not find the dll somewhere, the whole VM crashes. So this boils down to identify a place, where you can put leapjava.dylib. I did some research myself and you can view the readme of my leapjava mxj
      By the way: Do not confuse the leapjava.dylib/dll with leapjava.jar. The latter is the Java-side of the SDK so you got a control flow like:
      MaxMSP JavaVM / Your MXJ Leapjava.jar Leapjava.dylib
      The more to the right, the more nasty it gets.
    • Apr 07 2014 | 9:04 pm
      Hello Christoph,
      I am attempting to use your mxj in Windows 7 and I don't have an issue loading java in Max but I do have this error: "could not load class semmd.leapmotion"
      I followed your instructions in the readme to copy your classes and help file as well as the LeapJava.rar, LeapJava.dll, and Leap.dll to the respective Max folders. However, the only item named semmd.leapmotion was the Max help file and I placed it in the Java/Help folder, so I'm not sure how to solve my problem. Any advice?
    • Apr 07 2014 | 9:32 pm
      There is a folder named "semdd", which contains the java file "leapmotion.class". Move the whole folder to cycling74/java/classes and the class should load without complaint.
      Regards, Christoph
    • Apr 11 2014 | 8:30 pm
      Hello Christoph,
      I tried to use your mxj in Windows 8.1 and it works on Max5 but not Max6. It seems to be a java problem. I get a message that reads:
      mxj: could not find Java 2 Runtime Environment. Error loading: (mxj) mxj_platform_init failed. Could not initialize the Java Runtime Environment. Please check your Java installation. http://java.sun.com Unable to create JVM
      I have a thread about the issue if you have time to go through and see if something is not working properly: https://cycling74.com/forums/mxj-could-not-find-java-2-runtime-environment-and-mxj_platform_init-failed/