Package org.fusesource.jansi.internal
Class JansiLoader
- java.lang.Object
-
- org.fusesource.jansi.internal.JansiLoader
-
public class JansiLoader extends java.lang.Object
Set the system properties, org.jansi.lib.path, org.jansi.lib.name, appropriately so that jansi can find *.dll, *.jnilib and *.so files, according to the current OS (win, linux, mac). The library files are automatically extracted from this project's package (JAR). usage: callinitialize()
before using Jansi.
-
-
Field Summary
Fields Modifier and Type Field Description private static boolean
extracted
private static java.lang.String
nativeLibraryPath
private static java.lang.String
nativeLibrarySourceUrl
-
Constructor Summary
Constructors Constructor Description JansiLoader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static void
cleanup()
Deleted old native libraries e.g.private static java.lang.String
contentsEquals(java.io.InputStream in1, java.io.InputStream in2)
private static void
copy(java.io.InputStream in, java.io.OutputStream out)
private static boolean
extractAndLoadLibraryFile(java.lang.String libFolderForCurrentOS, java.lang.String libraryFileName, java.lang.String targetFolder)
Extracts and loads the specified library file to the target folderstatic int
getMajorVersion()
static int
getMinorVersion()
static java.lang.String
getNativeLibraryPath()
static java.lang.String
getNativeLibrarySourceUrl()
private static java.io.File
getTempDir()
static java.lang.String
getVersion()
private static boolean
hasResource(java.lang.String path)
static boolean
initialize()
Loads Jansi native library.private static java.lang.String
join(java.util.List<java.lang.String> list, java.lang.String separator)
private static void
loadJansiNativeLibrary()
Loads jansi library using given path and name of the library.private static boolean
loadNativeLibrary(java.io.File libPath)
Loads native library using the given path and name of the library.private static java.lang.String
randomUUID()
private static int
readNBytes(java.io.InputStream in, byte[] b)
-
-
-
Method Detail
-
initialize
public static boolean initialize()
Loads Jansi native library.- Returns:
- True if jansi native library is successfully loaded; false otherwise.
-
getNativeLibraryPath
public static java.lang.String getNativeLibraryPath()
-
getNativeLibrarySourceUrl
public static java.lang.String getNativeLibrarySourceUrl()
-
getTempDir
private static java.io.File getTempDir()
-
cleanup
static void cleanup()
Deleted old native libraries e.g. on Windows the DLL file is not removed on VM-Exit (bug #80)
-
readNBytes
private static int readNBytes(java.io.InputStream in, byte[] b) throws java.io.IOException
- Throws:
java.io.IOException
-
contentsEquals
private static java.lang.String contentsEquals(java.io.InputStream in1, java.io.InputStream in2) throws java.io.IOException
- Throws:
java.io.IOException
-
extractAndLoadLibraryFile
private static boolean extractAndLoadLibraryFile(java.lang.String libFolderForCurrentOS, java.lang.String libraryFileName, java.lang.String targetFolder)
Extracts and loads the specified library file to the target folder- Parameters:
libFolderForCurrentOS
- Library path.libraryFileName
- Library name.targetFolder
- Target folder.- Returns:
-
randomUUID
private static java.lang.String randomUUID()
-
copy
private static void copy(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
loadNativeLibrary
private static boolean loadNativeLibrary(java.io.File libPath)
Loads native library using the given path and name of the library.- Parameters:
libPath
- Path of the native library.- Returns:
- True for successfully loading; false otherwise.
-
loadJansiNativeLibrary
private static void loadJansiNativeLibrary() throws java.lang.Exception
Loads jansi library using given path and name of the library.- Throws:
java.lang.Exception
-
hasResource
private static boolean hasResource(java.lang.String path)
-
getMajorVersion
public static int getMajorVersion()
- Returns:
- The major version of the jansi library.
-
getMinorVersion
public static int getMinorVersion()
- Returns:
- The minor version of the jansi library.
-
getVersion
public static java.lang.String getVersion()
- Returns:
- The version of the jansi library.
-
join
private static java.lang.String join(java.util.List<java.lang.String> list, java.lang.String separator)
-
-