Can't find native files in a Processing tool

I am using Eclipse to create a Processing tool that uses OS native files and although the native files appear in the tools folder alongside the tool jar file, when I try and use the tool from Processing it cannot find them and I get the exception shown below.

Any idea how I should set my Eclipse project up to so that they will be visible in the final tool?

ProControlPlus Config Tool V1.0.0 created by Peter Lager

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no jinput-osx in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
    at java.lang.Runtime.loadLibrary0(Runtime.java:849)
    at java.lang.System.loadLibrary(System.java:1088)
    at net.java.games.input.OSXEnvironmentPlugin.(Unknown Source)
    at net.java.games.input.ControllerEnvironment.getEnvironment(Unknown Source)
    at org.game_controller.ControlIO.(Unknown Source)
    at org.game_controller.ControlIO.getInstance(Unknown Source)
    at org.game_control_tool.TSelectPApplet.initControlIO(Unknown Source)
    at org.game_control_tool.TSelectUI.(Unknown Source)
    at org.game_control_tool.ProControlPlusTool.run(Unknown Source)
    at processing.app.contrib.ToolContribution.run(ToolContribution.java:110)
    at processing.app.Editor$33.actionPerformed(Editor.java:985)

Answers

  • You might have guessed that I am updating and extending the ProControll library created by Christian Riekoff in 2005.

    So far I have modified the library so that it

    (1) is Processing 2 compliant (it no longer uses deprecated methods),

    (2) extended it so it works in Windows 64 bit systems

    (3) finds the input device based on a configuration file when the sketch is run

    (4) when the sketch is run, present the user with a visual interface to configure an alternative device if it can't find one to match the configuration file (without having to change the sketch code)

    So all this works and I have created some examples to go with the library.

    I have bumped this because I want to create a matching Tool to create the configuration files in the same way I created the GUI Builder tool to configure a G4P UI. Everything is there but the only problem is that when I try and use the tool from Processing it can't link to the native files even though it does in the library.

    So I would be very grateful to anyone who can help.

  • I'm not totally sure how Processing handles native libraries in tools, but your problem seems to be that Processing isn't adding your tool's directory to the library path.

    You might be able to get around this by manually setting it yourself, but there are problems with that approach as well.

    What you're looking to do is add your library's path to the java.library.path system property. That's the what, but I can't really give you the how. The tool I wrote handles this for you, but that probably won't help you for what you're doing.

  • Thanks for responding sometimes I get tunnel vision so another viewpoint is really useful.

    What you're looking to do is add your library's path to the java.library.path system property. That's the what, but I can't really give you the how.

    The how seemed straightforward using System.setProperty("java/library.path", ...) but as you can see below it didn't work. I have found some Processing source code for handling natives in libraries but nothing for tools (yet).

    ProControlPlus Config Tool V1.0.0 created by Peter Lager
    
    System property java.library.path (Start value)
    java.library.path: :/Applications/Processing.app/Contents/Java:/Applications/Processing.app/Contents/MacOS
    
    ProControl Plus system files path
    /Users/peter/Documents/Processing/tools/ProControlPlusTool/tool
    
    System property java.library.path (After adding tool folder)
    java.library.path: :/Users/peter/Documents/Processing/tools/ProControlPlusTool/tool:/Applications/Processing.app/Contents/Java:/Applications/Processing.app/Contents/MacOS
    
    Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no jinput-osx in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
        at java.lang.Runtime.loadLibrary0(Runtime.java:849)
    
  • Yeah, this is a convoluted issue. You can't just set the system property, as it's only read at the beginning of your program. There are ways around this by hacking the classloader, but that seems pretty gross to me.

    If you go the hack route, here are places describing the process: http://stackoverflow.com/questions/15961483/setting-djava-library-path-programmatically-or-alternatives and http://blog.cedarsoft.com/2010/11/setting-java-library-path-programmatically/

    The tool I wrote gets around this by using ProcessBuilder to relaunch the application, this time with the correct java.library.path passed in as a JVM parameter. I don't know whether that's a solution for you, since you'll then be in a different JVM than the original Processing window.

  • Thanks - that gives me something else to consider.

  • The addLibraryPath method described in your first link worked for me so many, many thanks for your help. =D>

Sign In or Register to comment.