Java and jSMILE

<< Click to Display Table of Contents >>

Navigation:  Platforms and Wrappers >

Java and jSMILE

jSMILE is compatible with JDK 8 and newer. See the Maven section below for information about using jSMILE in a Maven-based project, including the location of BayesFusion's Maven repository and POM integration with jSMILE's native library.

jSMILE contains two parts: the jar file and the native library, the latter is specific to your operating system. The jar file, named jsmile-x.y.z.jar where x.y.z is the version number, can be used as any Java jar.

The native library is used by the code in the jar file through Java Native Interface (JNI). The name of the native library file is platform-dependent:

jsmile.dll on Windows

jsmile.so on Linux

jsmile.jnilib on macOS

In the static initializer of the smile.Wrapper class, jSMILE will attempt to load its native library. If the jsmile.native.library system property is set, jSMILE calls System.load method, which requires a complete path name of the native library (no relative paths are allowed), using the value of the property as the path name. Otherwise, the System.loadLibrary method is used. In such case, the native library must be located in one of the directories specified by the java.library.path property. Note that java.library.path cannot be set once JVM is running, but jsmile.native.library can be set with a call to System.setProperty.

Your license key should be pasted into the source code of your program.

The classes defined in jSMILE are located in smile and smile.learning packages. There are two types of classes:

simple objects with public data members

wrappers for C++ objects from SMILE library

The second group of classes, which includes smile.Network, is derived from smile.Wrapper. Each object instance of these classes has a related C++ object, which is deallocated by the Java object's finalizer or by a call to Wrapper.Dispose method. To ensure early deallocation of C++ object resources associated with your Java object, Dispose should be called as soon as the program doesn't need the object anymore. If Dispose is not called, the deallocation will happen in the finalizer during garbage collection.