Class JansiLoader

java.lang.Object
org.fusesource.jansi.internal.JansiLoader

public class JansiLoader extends 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: call initialize() before using Jansi.

  • Field Details

    • loaded

      private static boolean loaded
    • nativeLibraryPath

      private static String nativeLibraryPath
    • nativeLibrarySourceUrl

      private static String nativeLibrarySourceUrl
  • Constructor Details

    • JansiLoader

      public JansiLoader()
  • Method Details

    • initialize

      public static boolean initialize()
      Loads Jansi native library.
      Returns:
      True if jansi native library is successfully loaded; false otherwise.
    • getNativeLibraryPath

      public static String getNativeLibraryPath()
    • getNativeLibrarySourceUrl

      public static String getNativeLibrarySourceUrl()
    • getTempDir

      private static 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(InputStream in, byte[] b) throws IOException
      Throws:
      IOException
    • contentsEquals

      private static String contentsEquals(InputStream in1, InputStream in2) throws IOException
      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

      private static String randomUUID()
    • loadNativeLibrary

      private static boolean loadNativeLibrary(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 Exception
      Loads jansi library using given path and name of the library.
      Throws:
      Exception
    • hasResource

      private static boolean hasResource(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 String getVersion()
      Returns:
      The version of the jansi library.