Class Loader
- java.lang.Object
-
- uk.co.xfactorylibrarians.coremidi4j.Loader
-
public class Loader extends Object
Loads the native library when we are running on a Mac. If necessary, extracts a copy of the library from our jar file to a temporary directory, to save the user the trouble of having to install it on their system. Arranges for that directory to be deleted when we exit. Inspired by the techniques used by usb4java, and the loader written by Klaus Raimer, k@ailis.de- Author:
- James Elliott
-
-
Field Summary
Fields Modifier and Type Field Description static String
NATIVE_LIBRARY_NAME
The file name of our native library.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isAvailable()
Checks whether CoreMidi4J is available on the current system, in other words whether it is a Mac OS X system and the native library was loaded successfully.static void
load()
Tries to load our native library.
-
-
-
Field Detail
-
NATIVE_LIBRARY_NAME
public static final String NATIVE_LIBRARY_NAME
The file name of our native library.- See Also:
- Constant Field Values
-
-
Method Detail
-
load
public static void load() throws CoreMidiException
Tries to load our native library. Can be safely called multiple times; duplicate attempts are ignored. This method is automatically called whenever any CoreMidi4J class that relies on JNI is loaded. If you need to do it earlier (to catch exceptions for example, or check whether the native library can be used), simply call this method manually.- Throws:
CoreMidiException
- if something unexpected happens trying to load the native library on a Mac OS X system.
-
isAvailable
public static boolean isAvailable() throws CoreMidiException
Checks whether CoreMidi4J is available on the current system, in other words whether it is a Mac OS X system and the native library was loaded successfully. Will attempt to perform that load if it has not yet occurred.- Returns:
- true if this is a Mac OS X system and the native library has been loaded successfully.
- Throws:
CoreMidiException
- if something unexpected happens trying to load the native library on a Mac OS X system.
-
-