mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
The JNI bindings are built directly into the shared library. In the gradle build, all built shared libraries are embedded into the generated jar. Java bindings may be disabled via -DWITHOUT_JAVA (cmake) or -PskipJava=true (gradle). TODO: - getEntryInfo() and RPC are not yet implemented. - The cmake build doesn't integrate the built objects into the jar. - The Java client and server tests are not built (but have been manually tested). This has not yet been tested on Windows.
27 lines
893 B
Java
27 lines
893 B
Java
import edu.wpi.first.wpilibj.networktables.*;
|
|
import edu.wpi.first.wpilibj.tables.*;
|
|
|
|
public class Server {
|
|
private static class MyLogger implements NetworkTablesJNI.LoggerFunction {
|
|
public void apply(int level, String file, int line, String msg) {
|
|
System.err.println(msg);
|
|
}
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
NetworkTablesJNI.setLogger(new MyLogger(), 0);
|
|
NetworkTable.setIPAddress("127.0.0.1");
|
|
NetworkTable.setPort(10000);
|
|
NetworkTable.setServerMode();
|
|
NetworkTable nt = NetworkTable.getTable("");
|
|
try { Thread.sleep(1000); } catch (InterruptedException e) {}
|
|
nt.putNumber("foo", 0.5);
|
|
nt.setFlags("foo", NetworkTable.PERSISTENT);
|
|
nt.putNumber("foo2", 0.5);
|
|
nt.putNumber("foo2", 0.7);
|
|
nt.putNumber("foo2", 0.6);
|
|
nt.putNumber("foo2", 0.5);
|
|
try { Thread.sleep(10000); } catch (InterruptedException e) {}
|
|
}
|
|
}
|