How do you enter values into a network tables in Java


What is the method for adding network table values using java (frc documentation is not working because the methods are deprecating)


I am assuming you are trying to get NT values off of something like a Raspberry Pi right? If so:

You need to create these 2 objects in robot:
public static NetworkTableInstance networkTableInstance = NetworkTableInstance.getDefault();
public static edu.wpi.first.networktables.NetworkTable networkTable;
The top one is the Instance and the bottom one is the actual table you are getting you’re data from
In RobotInit() you need to start your server and assign a keyname to your networktable:
networkTable = networkTableInstance.getTable(“networkTable”);
Then to actually get values off your networktable you do this where you want to retrieve your value (in this case a double):


is it essential to write networktableInstance.startServer()?


If I understand correctly, it is not essential to start the server manually with startServer() since RobotBase does it for you. Source:

If you use the non-default instance, it would be, but that’s probably not what you want to do here.


I posted some code here that might be helpful.