🛠️ P3/COBOL 25.1.0-SNAPSHOT is available for preview.
Reference Manual
P3-Utility
Build & Run

Command-line P3 Utility

To accommodate the convenient use of P3/COBOL and its Java-based utilities from the command line of the particular platform, a native executable is provided. This utility command is available for most platforms upon which P3 and Java will be deployed. Specifically, it is available for Linux, BSD Unix, OS X(Darwin), Solaris and Windows. For other platforms that are not directly supported, a shell script is provided ( p3.sh ).

💡

In order to use the p3 command, you must have set the P3_HOME environment variable and the p3 executable must be in a location where it will be found by the shell processor being used (or the Windows command line processor).

Several aspects of P3/COBOL, both compile-time and runtime, can be controlled by this p3 utility. The general form of the command is:

p3 command [subCommand] [javaArgs --] commandArgs\textsf{\textbf{p3}} \space \textit{command} \space \lbrack \textit{subCommand} \rbrack \space \lbrack \textit{javaArgs} \space \text{-} \text{-} \rbrack \space \textit{commandArgs}

💡

With this utility command any arguments to the JVM used to execute the Java subcommand (e.g., to set memory size) immediately follow the command (or, if present, the sub-command ) command and are always followed by --.

⚠️

The -j P3/COBOL compiler argument should not be used in this case.

Additional JavaArgs can be used in the p3 command, for example, to add memory to the JVM, when building large P3/COBOL projects:

p3 b -Xmx4g -- src-cobol/*.cbl

add memory for the JVM, when running a P3/COBOL program:

p3 r -Xmx4g -- -i hello-world

P3 Utility Commands

The command argument may be:

$ p3 help
 
The most commonly used p3 commands are:
    b(uild)                Build p3/cobol programs
    b(uild) r(eport)   br  Build p3/cobol programs with report
    r(un)   l(ocal)    rl  Run a p3/cobol program locally, or
    r(un)   r(emote)   rr  Run a p3/cobol program remotely (using app server)
    v(olume)               Run a p3/cobol volume utility
    s(erve) f(iles)    sf  Start a file server instance
    s(erve) a(pps)     sa  Start an app server instance, or
    s(erve) p(rograms) sp  Start an app server instance
 
Flags:
    --verbose          Verbose
    --version          Version
Command NamePurpose
b [uild]Build p3/cobol program(s)
b [uild] r[eport]Build p3/cobol program(s) with report
c [ompile]Compile p3/cobol program(s)
r [un]Run a p3/cobol program (either locally, or in a remote app server process)
v [olume]Run the p3/cobol volume management utility
s [erve]Start a server in this process (either applications server or file server)
h [elp] or ?Show this list

The syntax for each of these commands is as follows.

Compiling programs with the new build command

The file(s) determined by the arguments will be compiled by P3/COBOL and the resulting Java classes placed in the designated locations. The compilerArgs are specified in Compiler Options.

💡

If P3_HOME is defined, the P3/COBOL jar (p3cobol.jar) is searched at the following location:
$P3_HOME/lib/p3cobol.jar and automatically added to the CLASSPATH.

💡

If P3_HOME is not defined, the P3/COBOL jar (p3cobol.jar) is search in the CLASSPATH.

p3 b src-cobol/hello-world.cbl

In addition to the same behavior as the build command, a report is generated (console and report directory), including detailed information's, for example,

  • Total scheduled and compiled programs
  • Successful/Failed/Ignored programs
  • Build Performance
  • Missing copybooks
  • Separate error file (if any) per source, with detailed location information
p3 br src-cobol/hello-world.cbl

Compiling programs [deprecated]

The file(s) determined by the arguments will be compiled by P3/COBOL and the resulting Java classes placed in the designated locations.

p3 c src-cobol/hello-world.cbl

Running programs

The program determined by the arguments will be run in the command line process. The runtimeArgs are specified in Runtime Options. If a classpath is specified in the javaArgs provided, it will be modified to include the P3/COBOL jar determined by P3_HOME.

p3 r -i hello-world

The application program determined by the arguments will be run in the specified application server.

If javaArgs is specified, its options will be used to run the P3/COBOL application client, but will have no effect on the remote application server used by that client. If a classpath is specified in the javaArgs provided, it will be modified to include the P3/COBOL jar determined by P3_HOME.

p3 rr localhost 9090 hello-world "hello-args"