- java.lang.Object
-
- org.arakhne.afc.vmutil.LibraryLoader
-
public final class LibraryLoader extends Object
This class provides more generic means for loading dynamical libraries.The library loader may be enabled or not. When library loader is enable, it is able to retreive and load native libraries. When it is disable, it ignore all the loading queries.
- Version:
- 17.0 2020-01-04 14:41:35
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- vmutils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static URLfindLibraryURL(String libName)Replies the URL for the specified library.static URLfindLibraryURL(String path, String libName)Replies the URL for the specified library.(package private) static intgetOperatingSystemArchitectureDataModel()Replies the data model of the current operating system: 32 or 64 bits.static booleanisEnable()Replies if this library loader is enable.static voidload(File filename)Loads a code file with the specified filename from the local file system as a dynamic library.static voidload(String filename)Loads a code file with the specified filename from the local file system as a dynamic library.static voidload(URL filename)Loads a code file with the specified filename from the local file system as a dynamic library.static voidloadLibrary(String libname)Loads the system library specified by thelibnameargument.static voidloadPlatformDependentLibrary(String libname)Search and load the dynamic library which is fitting the current operating system (32 or 64bits operating system...).static voidloadPlatformDependentLibrary(String path, String libname)Search and load the dynamic library which is fitting the current operating system (32 or 64bits operating system...).(package private) static voidloadPlatformDependentLibrary(String libname, String platform, String... paths)Search and load the dynamic library which is fitting the current operating system (32 or 64bits operating system...).static voidsetEnable(boolean enable)Replies if this library loader is enable.
-
-
-
Method Detail
-
isEnable
@Pure public static boolean isEnable()
Replies if this library loader is enable.The library loader is able to load native libraries when it is enable. Otherwise it ignore all the loading queries.
- Returns:
trueif the library loader is enable, otherwisefalse- Since:
- 5.0
-
setEnable
public static void setEnable(boolean enable)
Replies if this library loader is enable.The library loader is able to load native libraries when it is enable. Otherwise it ignore all the loading queries.
- Parameters:
enable- istrueto allow this loader to retreive native libraries, orfalseto ignore all the loading queries.- Since:
- 5.0
-
load
public static void load(String filename)
Loads a code file with the specified filename from the local file system as a dynamic library. The filename argument must be a complete path name.The call
LibraryLoader.load(name)is effectively equivalent to the call:System.load(name)
- Parameters:
filename- is the file to load.- Throws:
SecurityException- if a security manager exists and itscheckLinkmethod doesn't allow loading of the specified dynamic libraryUnsatisfiedLinkError- if the file does not exist.NullPointerException- iffilenameisnull- See Also:
System.load(java.lang.String)
-
load
public static void load(URL filename) throws IOException
Loads a code file with the specified filename from the local file system as a dynamic library. The filename argument must be a complete path name.- Parameters:
filename- is the file to load.- Throws:
IOException- when reading error occurs.SecurityException- if a security manager exists and itscheckLinkmethod doesn't allow loading of the specified dynamic libraryUnsatisfiedLinkError- if the file does not exist.NullPointerException- iffilenameisnull- See Also:
System.load(java.lang.String)
-
load
public static void load(File filename)
Loads a code file with the specified filename from the local file system as a dynamic library. The filename argument must be a complete path name.The call
LibraryLoader.load(name)is effectively equivalent to the call:System.load(name.getAbsolutePath())
- Parameters:
filename- is the file to load.- Throws:
SecurityException- if a security manager exists and itscheckLinkmethod doesn't allow loading of the specified dynamic libraryUnsatisfiedLinkError- if the file does not exist.NullPointerException- iffilenameisnull- See Also:
System.load(java.lang.String)
-
loadLibrary
public static void loadLibrary(String libname)
Loads the system library specified by thelibnameargument. The manner in which a library name is mapped to the actual system library is system dependent.The call
LibraryLoader.loadLibrary(name)is effectively equivalent to the callSystem.loadLibrary(name)
- Parameters:
libname- the name of the library.- Throws:
SecurityException- if a security manager exists and itscheckLinkmethod doesn't allow loading of the specified dynamic libraryUnsatisfiedLinkError- if the library does not exist.NullPointerException- iflibnameisnull- See Also:
System.loadLibrary(java.lang.String)
-
findLibraryURL
@Pure public static URL findLibraryURL(String libName)
Replies the URL for the specified library.- Parameters:
libName- is the name of the library- Returns:
- the URL where the specified library was located.
-
findLibraryURL
@Pure public static URL findLibraryURL(String path, String libName)
Replies the URL for the specified library.The call
LibraryLoader.findLibraryURL(path,name)is effectively equivalent to the call:getClassLoader().getResource(path+System.mapLibraryName(name))
- Parameters:
path- is the resource's path where the library was located.libName- is the name of the library- Returns:
- the URL where the specified library was located.
-
getOperatingSystemArchitectureDataModel
@Pure static int getOperatingSystemArchitectureDataModel()
Replies the data model of the current operating system: 32 or 64 bits.- Returns:
- the integer which is corresponding to the data model, or
0if it could not be determined.
-
loadPlatformDependentLibrary
public static void loadPlatformDependentLibrary(String libname) throws IOException
Search and load the dynamic library which is fitting the current operating system (32 or 64bits operating system...). A 64 bits library is assumed to be namedlibname64.dllon Windows® andliblibname64.soon Unix. A 32 bits library is assumed to be namedlibname32.dllon Windows® andliblibname32.soon Unix. A library which could be ran either on 32 and 64 platforms is assumed to be namedlibname.dllon Windows® andliblibname.soon Unix.- Parameters:
libname- is the name of the library.- Throws:
IOException- when reading error occurs.SecurityException- if a security manager exists and itscheckLinkmethod doesn't allow loading of the specified dynamic libraryUnsatisfiedLinkError- if the file does not exist.NullPointerException- iffilenameisnull- See Also:
System.load(java.lang.String)
-
loadPlatformDependentLibrary
public static void loadPlatformDependentLibrary(String path, String libname) throws IOException
Search and load the dynamic library which is fitting the current operating system (32 or 64bits operating system...). A 64 bits library is assumed to be namedlibname64.dllon Windows® andliblibname64.soon Unix. A 32 bits library is assumed to be namedlibname32.dllon Windows® andliblibname32.soon Unix. A library which could be ran either on 32 and 64 platforms is assumed to be namedlibname.dllon Windows® andliblibname.soon Unix.- Parameters:
path- is the resource's path where the library was located.libname- is the name of the library.- Throws:
IOException- when reading error occurs.SecurityException- if a security manager exists and itscheckLinkmethod doesn't allow loading of the specified dynamic libraryUnsatisfiedLinkError- if the file does not exist.NullPointerException- iffilenameisnull- See Also:
System.load(java.lang.String)
-
loadPlatformDependentLibrary
static void loadPlatformDependentLibrary(String libname, String platform, String... paths) throws IOException
Search and load the dynamic library which is fitting the current operating system (32 or 64bits operating system...). A 64 bits library is assumed to be namedlibname64.dllon Windows® andliblibname64.soon Unix. A 32 bits library is assumed to be namedlibname32.dllon Windows® andliblibname32.soon Unix. A library which could be ran either on 32 and 64 platforms is assumed to be namedlibname.dllon Windows® andliblibname.soon Unix.- Parameters:
libname- is the name of the library.platform- is the name of the current OS platform.paths- are the resource's paths where the library was located.- Throws:
IOException- when reading error occurs.SecurityException- if a security manager exists and itscheckLinkmethod doesn't allow loading of the specified dynamic libraryUnsatisfiedLinkError- if the file does not exist.NullPointerException- iffilenameisnull- See Also:
System.load(java.lang.String)
-
-