Installing FANN on Java project and NativeLibrary.loadLibrary problems with 32bit/64bit

If you try to install FANN and get it working with a Java project you might run into a few problems. The whole process is explained on the fannj (the Java binding) project's wiki but not in great detail.

Installing Fannj

  1. Get fannj
  2. Store it somewhere and add the jar to your project.
  3. Get FANN
  4. Extract it somewhere.
  5. Set up the DLL by either:
    • copying the fannfloat.dll to System32, or
    • adding the following line before you try to use FANN:  System.setProperty("jna.library.path", [fannfloat.dll dir path]);

Solutions to common issues

No Java Native

"Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Platform"

Solution: Download the JNA and add the jar to your project.

Can' find the FANN library

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'fannfloat': The specified module could not be found.

Solution: Add debugging code (or better yet: use a debugger) after you set the JNA library path

Mismatch between JDK and DLL - 64bit vs 32bit

Exception in thread "main" java.lang.UnsatisfiedLinkError: [ddl path]: Can't load IA 32-bit .dll on a AMD 64-bit platform

You are probably running a 64bit Java SDK while fannfloat.dll is 32bit. The solution for me was installing additional 32bit Java SDK and choosing it in the build path for my project.

Refrences

Comments

  1. Just added this helpful information to the FannJ wiki page. If you can think of other ways FannJ can be improved, let us know. Thanks!

    ReplyDelete
  2. Great, glad I could help. :)

    ATM I got nothing, but I'll be sure to contact you guys if something comes to my mind.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. this is only for PC, right??

    can i run this fannj on device android using eclipse??

    ReplyDelete
  6. Огромное спасибо за помощь! )

    ReplyDelete

Post a Comment

Popular posts from this blog

MongoDB and distinct values in arrays

Creation method in Mongoose.js, alternative to custom constructor or hooks