Skip to content

Commit a54d2b5

Browse files
authored
Merge pull request #54 from ChristianSchulte/master
java.lang.UnsatisfiedLinkError when native library is not found.
2 parents 03e7a2a + 823ee46 commit a54d2b5

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java

+23-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,34 @@
3535
public class AnsiConsole {
3636

3737
public static final PrintStream system_out = System.out;
38-
public static final PrintStream out = new PrintStream(wrapOutputStream(system_out));
38+
public static final PrintStream out;
3939

4040
public static final PrintStream system_err = System.err;
41-
public static final PrintStream err = new PrintStream(wrapOutputStream(system_err, STDERR_FILENO));
41+
public static final PrintStream err;
4242

4343
private static int installed;
4444

45+
static
46+
{
47+
PrintStream jansiOut;
48+
PrintStream jansiErr;
49+
50+
try
51+
{
52+
jansiOut = new PrintStream( wrapOutputStream( system_out ) );
53+
jansiErr = new PrintStream( wrapOutputStream( system_err, STDERR_FILENO ) );
54+
}
55+
catch ( final UnsatisfiedLinkError e )
56+
{
57+
// Failure loading native library.
58+
jansiOut = system_out;
59+
jansiErr = system_err;
60+
}
61+
62+
out = jansiOut;
63+
err = jansiErr;
64+
}
65+
4566
private AnsiConsole() {
4667
}
4768

0 commit comments

Comments
 (0)