Skip to content
Java bindings to the Fast Artificial Neural Network (FANN) C library.
Java Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
releases
src
.gitignore
.travis.yml compile libflann on-the-fly and attach as native jar Mar 7, 2016
LICENSE Migration from googlecode Aug 8, 2014
README.md
linux-native-build.sh put native linux lib at correct location in jar such that the jna loa… Mar 9, 2016
nbactions.xml Updated tests to work with FANN 2.2.0 Mar 24, 2015
pom.xml put native linux lib at correct location in jar such that the jna loa… Mar 9, 2016

README.md

fannj

Java bindings to FANN, the Fast Artificial Neural Network C library.

Overview

Use FannJ if you have an existing ANN from the FANN project that you would like to access from Java. There are several GUI tools that will help you create and train an ANN.

Installation

Before using FannJ, you must build and install the FANN C library. FannJ has been tested on FANN 2.2.0. See the FANN site for instructions and help: http://leenissen.dk/fann

Code Example

Fann fann = new Fann( "/path/to/file" );
float[] inputs = new float[]{ -1, 1 };
float[] outputs = fann.run( inputs );
fann.close();

Dependencies

FANN - Does all the work.

JNA - Provides the native access to FANN.

Maven 2 Support

This project is now in the Maven Central Repository.

<dependencies>
    <dependency>
        <groupId>com.googlecode.fannj</groupId>
        <artifactId>fannj</artifactId>
        <version>0.7</version>
    </dependency>
</dependencies>

Running

JNA provides the binding from Java to the FANN C library via JNI. You must set the jna.library.path system property to the path to the FANN Library. This property is similar to java.library.path but only applies to libraries loaded by JNA. You should also change the appropriate library access environment variable before launching the VM. This is PATH on Windows, LD_LIBRARY_PATH on Linux, and DYLD_LIBRARY_PATH on OSX.

Linux something like:

LD_LIBRARY_PATH=/usr/local/lib

java -Djna.library.path=/usr/local/lib -cp fannj-0.7.jar:jna-3.2.2.jar YourClass

Update: the maven descriptor (pom.xml) now contains a section (atm only for Linux) that builds FANN from sources and packs the native library into a jar file called fannj-<version>-linux-x86_64.jar. If you put that jar onto the classpath, the JNA libs should be able to extract and load the contained libs all by themselves and without additional configuration.

You can’t perform that action at this time.