Skip navigation links

Perforce Java API 2017.2.1635107 API

P4J -- Java Access to Perforce SCM Services

See: Description

Packages 
Package Description
com.perforce.p4java
Defines the root of the Perforce P4Java API product package hierarchy and a small handful of useful product-wide definitions and services such as loggers, tracers, and product metadata.
com.perforce.p4java.admin  
com.perforce.p4java.charset  
com.perforce.p4java.client
Provides interfaces for accessing and manipulating Perforce client workspaces and associated objects.
com.perforce.p4java.common.base  
com.perforce.p4java.common.function  
com.perforce.p4java.core
Provides interfaces and classes for defining and accessing Perforce objects such as jobs, changelists, etc., and, through the file sub-package, Perforce files.
com.perforce.p4java.core.file
Provides interfaces and classes for defining and accessing Perforce depot and workspace files.
com.perforce.p4java.env  
com.perforce.p4java.exception
Provides exception and error classes for signaling and handling user, internal, and Perforce server errors.
com.perforce.p4java.graph  
com.perforce.p4java.impl.generic.admin  
com.perforce.p4java.impl.generic.client
Provides standard implementation classes for the com.perforce.p4java.client interfaces.
com.perforce.p4java.impl.generic.core
Provides standard implementation classes for the com.perforce.p4java.core interfaces.
com.perforce.p4java.impl.generic.core.file
Provides standard implementation classes for the com.perforce.p4java.core.file interfaces.
com.perforce.p4java.impl.generic.graph  
com.perforce.p4java.impl.generic.sys
Provides one or more "helper" and other classes to assist P4Java with typical operating system operations that can not always be done efficiently (or at all) in Java.
com.perforce.p4java.impl.mapbased  
com.perforce.p4java.impl.mapbased.client  
com.perforce.p4java.impl.mapbased.rpc  
com.perforce.p4java.impl.mapbased.rpc.connection  
com.perforce.p4java.impl.mapbased.rpc.func  
com.perforce.p4java.impl.mapbased.rpc.func.client  
com.perforce.p4java.impl.mapbased.rpc.func.helper  
com.perforce.p4java.impl.mapbased.rpc.func.proto  
com.perforce.p4java.impl.mapbased.rpc.func.user  
com.perforce.p4java.impl.mapbased.rpc.helper  
com.perforce.p4java.impl.mapbased.rpc.msg  
com.perforce.p4java.impl.mapbased.rpc.packet  
com.perforce.p4java.impl.mapbased.rpc.packet.helper  
com.perforce.p4java.impl.mapbased.rpc.stream  
com.perforce.p4java.impl.mapbased.rpc.stream.helper  
com.perforce.p4java.impl.mapbased.rpc.sys  
com.perforce.p4java.impl.mapbased.rpc.sys.helper  
com.perforce.p4java.impl.mapbased.server  
com.perforce.p4java.impl.mapbased.server.cmd  
com.perforce.p4java.io.apple  
com.perforce.p4java.messages  
com.perforce.p4java.option
Provides a series of classes that implement P4Java-wide server, client, and other class method options definitions and processing.
com.perforce.p4java.option.changelist  
com.perforce.p4java.option.client  
com.perforce.p4java.option.server  
com.perforce.p4java.server
Provides interfaces and classes for accessing Perforce SCM servers and associated server-level services.
com.perforce.p4java.server.callback
Provides interfaces and classes for defining and accessing Perforce server callbacks for things like logging, command progress, single sign on (SSO) authentication, etc.
com.perforce.p4java.server.delegator  
com.perforce.p4java.util  

P4J -- Java Access to Perforce SCM Services

The Perforce P4J Java API provides access to Perforce software configuration management services through a Java-natural API.

P4J is intended for use in standalone and embedded products such as Perforce's P4WSAD Eclipse plug-in or third-party products. P4J does not support all possible Perforce server commands. In particular, P4J does not support some of the more obscure Perforce admin or job-related commands, but the set of services available through P4J is intended to be useful and sufficient for day-to-day developer work and for most scripted applications.

P4J allows the user to select a protocol for communicating with Perforce servers (see the P4JServerFactory class in the com.perforce.p4j.server package); the details of these protocols are typically fairly opaque, but currently the two major protocol implementations use the Perforce C++ API or the Perforce p4 command-line interpreter respectively.

P4J assumes JDK 5 or later (it makes extensive use of parameterized types, for example), and -- depending on the protocol chosen -- your environment must include a working p4 command line interpreter (which comes with every Perforce installation) or the C++ API (optionally available from Perforce's website). In most client configurations, one or both of these will already be installed in any case -- ask your IT staff.

The main P4J usage model is described in detail elsewhere, but in summary, the vast majority of uses start with the server factory, P4JServerFactory; this factory is used to obtain a P4JServer object that can be used to issue commands to the associated Perforce server. Other important interfaces and objects include the P4JClient (usually obtained through a P4JServer method call), which is used to issue Perforce client-specific commands (such as Perforce client workspace file edit, add, delete, and sync operations); the P4JChangeList interface for Perforce changelists; and the various Perforce file interfaces for interrogating and managing Perforce-managed files.

Note that P4J is thread-safe when each thread uses its own P4JServer object and subsidiary objects; other usage models do not guarantee thread-safety.

Skip navigation links

Copyright © 2018 Perforce Software. All Rights Reserved.