Provides classes for accessing Perforce objects (LICENSE). These classes can be used to write higher-level scripts and applications in Java, which is the definition of an API.

This software is provided 'AS IS' with NO WARRANTY!

The current implementation acts as a wrapper around the execution of command line requests. There has been some development done in an attempt to utilize the P4API directly through the Java Native Interface. When this work is completed, it will be possible convert to its use without changing the underlying objects.

Usage Overview

The key classes in this package are {@link com.perforce.api.Env Env} and {@link com.perforce.api.P4Process P4Process}. All the remaining object representation rely on these two. The Env must be instantiated and configured before using it with other classes. The P4Process may never be instantiated directly, but it is where the actual command is executed. This is extremely useful, if the classes provided do not provide the functionality you need.

Example

In this example, the method performs and integration and commits the change.
public void doIt() {
  {@link com.perforce.api.Env Env} env;
  {@link com.perforce.api.Change Change} chng;
  StringBuffer sb;

  env = new Env();
  env.setUser("jdoe");
  env.setPassword("secret");
  env.setClient("jdoe-pc");

  chng = new Change(env);
  chng.setDescription("Integration from staging to release.");
  try {
    chng.store();
    sb = new StringBuffer();
    chng = {@link com.perforce.api.Branch Branch}.{@link com.perforce.api.Branch#integrate(Env, String, String, StringBuffer, Change) integrate}(env, "//depot/docs/stage/...",
                            "stage2release", sb, chng);
    chng.submit();
  } catch (CommitException e) {
    System.err.println("Unable to store new change.");
  } catch (SubmitException e) {
    System.err.println("Unable to submit changelist into Perforce.");
  } catch (PerforceException e) {
    System.err.println("Unable to integrate files: "+sb);
  }
}
Last Updated: $Date: 2001/11/02 $ $Revision: #5 $ @see LICENSE