libConsole/Console.java
author Markus Bröker<broeker.markus@googlemail.com>
Sat, 21 Oct 2017 13:45:05 +0200
changeset 171 c6e0af68825a
parent 134 8325a0fc22cd
permissions -rw-r--r--
Entrypoint and RET fixed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
134
8325a0fc22cd simple corrections
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 83
diff changeset
     1
import java.io.File;
8325a0fc22cd simple corrections
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 83
diff changeset
     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
8325a0fc22cd simple corrections
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 83
diff changeset
     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
}