NativeLibLoader

public class NativeLibLoader

Class to load the native lib libtreelite4j.dylib. Normally, users do not have to worry about this class, since mvn package automatically bundles libtreelite4j.dylib into the JAR file. However, the method createTempFileFromResource may be useful to some users, who would like to bundle other files into the JAR file as well.

Author:Philip Cho

Methods

createTempFileFromResource

public static String createTempFileFromResource(String path)

Create a temp file that copies the resource from current JAR archive

The file from JAR is copied into system temp file. The temporary file is deleted after exiting. Method uses String as filename because the pathname is “abstract”, not system-dependent.

The restrictions of File.createTempFile(java.lang.String,java.lang.String) apply to path.

Parameters:
  • path – Path to the resources in the jar
Throws:
  • IOException – When the temp file could not be created
  • IllegalArgumentException – When the file name contains invalid letters
Returns:

The created temp file.

initTreeliteRuntime

static synchronized void initTreeliteRuntime()

Initialization method to load the native treelite4j lib at startup

Throws:
  • IOException – when treelite4j lib is not found