P4Java properties

P4Java uses Java properties to set various operational values for specific IServer instances and/or for P4Java as a whole. These properties are typically used for things like preferred temporary file directory locations, application version and name information for Helix Server usage, and the location of a suitable Helix Server authentication tickets file (see Authentication for details). A full list of publicly-visible properties (with default values) is given in the PropertyDefs Javadoc.

Properties intended for P4Java use can have “long form” or “short form” names. Long form names are canonical, and are always prefixed by the string represented by PropertyDefs.P4JAVA_PROP_KEY_PREFIX (normally com.perforce.p4java., for example, com.perforce.p4java.userName). Short form names are the same string without the standard prefix (for example, userName). Use long form names when there’s any chance of conflict with system or other properties; short form names, on the other hand, are convenient for putting property values onto URI strings as long as you know the property name won’t collide with another property name in use by the app or system.

Properties can be passed to P4Java in several ways:

The following code shows an example of passing properties to a IServer instance using the URI string query mechanism:

IServer server = ServerFactory.getServer(
  "p4java://test:1666?userName=test12&clientName=test12_client&"
  + "autoConnect=y", null);

Assuming no errors occur along the way, this code returns a IServer object connected to the Helix Server host test on port 1666 with the Helix Server client name test12_client and Helix Server user name test12 logged in automatically (note that the login only works if the underlying authentication succeeds — see Authentication for details.