public final class LibUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
LibUtils.ArchType
Enumeration of common CPU architectures.
|
static class |
LibUtils.OSType
Enumeration of common operating systems, independent of version
or architecture.
|
Modifier and Type | Method and Description |
---|---|
static LibUtils.ArchType |
calculateArch()
Calculates the current ARCHType
|
static LibUtils.OSType |
calculateOS()
Calculates the current OSType
|
static String |
createLibraryFileName(String libraryName)
/**
Create the full library file name, including the extension
and prefix, for the given library name.
|
static String |
createPlatformLibraryName(String baseName)
Creates the name for the native library with the given base name for
the current platform, by appending strings that indicate the current
operating system and architecture.
|
static void |
loadLibrary(String libraryName,
String... dependentLibraryNames)
Loads the specified library.
|
public static void loadLibrary(String libraryName, String... dependentLibraryNames)
System.loadLibrary
call. In this case, the specified
dependent libraries are ignored, because they are assumed to be
loaded automatically in the same way as the main library.System.loadLibrary
call, then this method will attempt
to load the file as a resource (usually one that is contained in
a JAR file). In this case, the library is assumed to be located
in subdirectory called "/lib"
inside the JAR file.
The method will try to load a resource that has the platform-specific
library file name
from
this directory, extract it into the default directory for temporary
files, and load the library from there. osString()
and
archString()
of the executing platform. For example, such
a library may be located in a directory inside the JAR that is
called "/lib/windows/x86_64"
. These dependent libraries
will be extracted and loaded before the main library is loaded.libraryName
- The name of the library (without a platform specific
prefix or file extension)dependentLibraryNames
- The names of libraries that the library
to load depends on. If the library is loaded as a resource, then
it will be attempted to also load these libraries as resources, as
described aboveUnsatisfiedLinkError
- if the native library
could not be loaded.public static String createLibraryFileName(String libraryName)
libraryName
- The library namepublic static String createPlatformLibraryName(String baseName)
baseName-OSType-ArchType
OSType
and
ArcType
enum constants.EXAMPLE-windows-x86
baseName
- The base name of the librarypublic static LibUtils.OSType calculateOS()
public static LibUtils.ArchType calculateArch()
Copyright © 2020. All rights reserved.