Package org.jline.nativ
Class JLineNativeLoader
java.lang.Object
org.jline.nativ.JLineNativeLoader
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static void
cleanup()
Deleted old native libraries e.g.private static String
contentsEquals
(InputStream in1, InputStream in2) private static void
copy
(InputStream in, OutputStream out) private static boolean
extractAndLoadLibraryFile
(String libFolderForCurrentOS, String libraryFileName, String targetFolder) Extracts and loads the specified library file to the target folderstatic int
static int
static String
static String
private static File
static String
private static boolean
hasResource
(String path) static boolean
Loads jline native library.private static String
private static void
Loads jline library using given path and name of the library.private static boolean
loadNativeLibrary
(File libPath) Loads native library using the given path and name of the library.private static String
private static int
readNBytes
(InputStream in, byte[] b)
-
Field Details
-
loaded
private static boolean loaded -
nativeLibraryPath
-
nativeLibrarySourceUrl
-
-
Constructor Details
-
JLineNativeLoader
public JLineNativeLoader()
-
-
Method Details
-
initialize
public static boolean initialize()Loads jline native library.- Returns:
- True if jline native library is successfully loaded; false otherwise.
-
getNativeLibraryPath
-
getNativeLibrarySourceUrl
-
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
- Throws:
IOException
-
contentsEquals
- Throws:
IOException
-
extractAndLoadLibraryFile
private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, String libraryFileName, 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
-
copy
- Throws:
IOException
-
loadNativeLibrary
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
Loads jline library using given path and name of the library.- Throws:
Exception
-
hasResource
-
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
- Returns:
- The version of the jline library.
-
join
-