jcuda
Class LibUtils

java.lang.Object
  extended by jcuda.LibUtils

public class LibUtils
extends java.lang.Object

Utility class for detecting the operating system and architecture types, and automatically loading the matching native library.

Adapted from http://javablog.co.uk/2007/05/19/making-jni-cross-platform/
Extended with http://lopica.sourceforge.net/os.html


Nested Class Summary
static class LibUtils.ARCHType
          Enumeration of common CPU architectures.
static class LibUtils.OSType
          Enumeration of common operating systems, independent of version or architecture.
 
Method Summary
static LibUtils.ARCHType calculateArch()
          Calculates the current ARCHType
static LibUtils.OSType calculateOS()
          Calculates the current OSType
static java.lang.String createLibName(java.lang.String baseName)
          Creates the name for the native library with the given base name for the current operating system and architecture.
static void loadLibrary(java.lang.String baseName)
          Loads the specified library.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadLibrary

public static void loadLibrary(java.lang.String baseName)
Loads the specified library. The full name of the library is created by calling createLibName(String) with the given argument.

Parameters:
baseName - The base name of the library
Throws:
java.lang.UnsatisfiedLinkError - if the native library can not be loaded.

createLibName

public static java.lang.String createLibName(java.lang.String baseName)
Creates the name for the native library with the given base name for the current operating system and architecture. The resulting name will be of the form
baseName-OSType-ARCHType
where OSType and ARCHType are the lower case Strings of the respective enum constants. Example:
JCuda-windows-x86

Parameters:
baseName - The base name of the library
Returns:
The library name

calculateOS

public static LibUtils.OSType calculateOS()
Calculates the current OSType

Returns:
The current OSType

calculateArch

public static LibUtils.ARCHType calculateArch()
Calculates the current ARCHType

Returns:
The current ARCHType