libConsole/Console.java
author Markus Bröker <mbroeker@largo.dyndns.tv>
Thu, 16 Apr 2009 12:50:39 +0200
changeset 67 abe63a276a36
parent 55 2a20d0184041
child 83 220d76d0d672
permissions -rw-r--r--
file traversal demo && minor changes Traversal through a filesystem hierarchy made easy committer: Markus Bröker <mbroeker@largo.homelinux.org>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49
77094ec383cf libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     1
public class Console {
77094ec383cf libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
     2
    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
     3
    private static void help () {
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
     4
        String p = System.getProperty ("java.library.path");
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
     5
        String[] msg = p.split (":");
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
     6
        System.err.printf ("Console Error:\n");
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
     7
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
     8
        for (int i = 0; i < msg.length; i++)
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
     9
            System.err.printf ("\t%s\n", msg[i]);
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
    10
        System.exit (-1);
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
    11
    };
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
    12
49
77094ec383cf libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    13
    static {
55
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
    14
        try {
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
    15
            System.loadLibrary ("Console");
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
    16
        } catch (UnsatisfiedLinkError ule) {
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
    17
            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
    18
            help ();
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
    19
        }
2a20d0184041 Console aborts with return code -1 on error
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 49
diff changeset
    20
    };
49
77094ec383cf libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    21
}