From 823ee46d7034784d15d130a15a7ae45874d261fb Mon Sep 17 00:00:00 2001 From: Christian Schulte Date: Mon, 13 Jun 2016 14:29:31 +0200 Subject: [PATCH] java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no jansi64-1.12 in java.library.path, no jansi-1.12 in java.library.path, no jansi in java.library.path] --- .../org/fusesource/jansi/AnsiConsole.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java b/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java index 03ccf15f..31b6b50c 100644 --- a/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java +++ b/jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java @@ -35,13 +35,34 @@ public class AnsiConsole { public static final PrintStream system_out = System.out; - public static final PrintStream out = new PrintStream(wrapOutputStream(system_out)); + public static final PrintStream out; public static final PrintStream system_err = System.err; - public static final PrintStream err = new PrintStream(wrapOutputStream(system_err, STDERR_FILENO)); + public static final PrintStream err; private static int installed; + static + { + PrintStream jansiOut; + PrintStream jansiErr; + + try + { + jansiOut = new PrintStream( wrapOutputStream( system_out ) ); + jansiErr = new PrintStream( wrapOutputStream( system_err, STDERR_FILENO ) ); + } + catch ( final UnsatisfiedLinkError e ) + { + // Failure loading native library. + jansiOut = system_out; + jansiErr = system_err; + } + + out = jansiOut; + err = jansiErr; + } + private AnsiConsole() { }