Package org.jline.nativ
Class JLineNativeLoader
- java.lang.Object
-
- org.jline.nativ.JLineNativeLoader
-
public class JLineNativeLoader extends java.lang.Object
Set the system properties, library.jline.path, library.jline.name, appropriately so that jline 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: call
initialize()
before using jline.
-
-
Field Summary
Fields Modifier and Type Field Description private static boolean
loaded
private static java.lang.String
nativeLibraryPath
private static java.lang.String
nativeLibrarySourceUrl
-
Constructor Summary
Constructors Constructor Description JLineNativeLoader()
-
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 jline native library.private static java.lang.String
join(java.util.List<java.lang.String> list, java.lang.String separator)
private static void
loadJLineNativeLibrary()
Loads jline 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 jline native library.- Returns:
- True if jline 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.
-
loadJLineNativeLibrary
private static void loadJLineNativeLibrary() throws java.lang.Exception
Loads jline 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 jline library.
-
getMinorVersion
public static int getMinorVersion()
- Returns:
- The minor version of the jline library.
-
getVersion
public static java.lang.String getVersion()
- Returns:
- The version of the jline library.
-
join
private static java.lang.String join(java.util.List<java.lang.String> list, java.lang.String separator)
-
-