P4 Server addresses, URIs, and properties

P4 API for Java uses a URI string format to specify the network location of target P4 Servers. This URI string format is described in detail in the server factory documentation, but it always includes at least the server’s hostname and port number, and a scheme part that indicates a P4 API for Java connection (for example, p4java://localhost:1666). Note that:

  • P4 API for Java does not obtain default values from the execution environment or other sources for any part of the URI string. All non-optional parts of the URI must be filled in. (For example, P4 API for Java does not attempt to retrieve the value of P4PORT from a Unix or Linux environment to complete a URL with a missing port number.)
  • P4 API for Java’s factory methods allow you to pass properties into the IOptionsServer object in the server’s URI string as query parts that override any properties that are passed in through the normal properties parameter in the server factory getServer method. This feature is somewhat limited in that it doesn’t currently implement URI escape sequence parsing in the query string, but it can be very convenient for properties passing. See P4 API for Java properties for an explanation.