author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Fri, 27 Dec 2013 16:00:09 +0100 | |
changeset 167 | 7c6b221900bf |
parent 134 | 8325a0fc22cd |
permissions | -rw-r--r-- |
134 | 1 |
import java.io.File; |
2 |
||
49
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
3 |
public class Console { |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
4 |
public static native int getch (); |
55
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
5 |
private static void help () { |
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
6 |
String p = System.getProperty ("java.library.path"); |
134 | 7 |
String[] msg = p.split (File.pathSeparator); |
83
220d76d0d672
Platform Independend Newlines
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
55
diff
changeset
|
8 |
System.err.printf ("Console Error:%n"); |
55
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
9 |
|
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
10 |
for (int i = 0; i < msg.length; i++) |
83
220d76d0d672
Platform Independend Newlines
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
55
diff
changeset
|
11 |
System.err.printf ("\t%s%n", msg[i]); |
55
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
12 |
System.exit (-1); |
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
13 |
}; |
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
14 |
|
49
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
15 |
static { |
55
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
16 |
try { |
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
17 |
System.loadLibrary ("Console"); |
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
18 |
} catch (UnsatisfiedLinkError ule) { |
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
19 |
System.err.println (ule.getLocalizedMessage ()); |
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
20 |
help (); |
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
21 |
} |
2a20d0184041
Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
49
diff
changeset
|
22 |
}; |
49
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
23 |
} |