Java™ programs run in a batch job by using the Submit Job (SBMJOB) command. In this mode, the Java Qshell Command Entry display is not available to handle the System.in, System.out, nor System.err streams.
You may redirect these streams to other files. Default handling sends the System.out and System.err streams to a spooled file. The batch job, which results in an input and output exception for read requests from System.in, owns the spooled file. You can redirect System.in, System.out, and System.err within your Java program. You can also use the os400.stdin, os400.stdout, and os400.stderr system properties to redirect System.in, System.out, and System.err.
Example: Running Java in a Batch Job
SBMJOB CMD(JAVA Hello OPTION(*VERBOSE)) CPYENVVAR(*YES)
Running the JAVA command in the previous example spawns a second job. Therefore, the subsystem that the batch job runs in must be capable of running more than one job.
You can verify that your batch job is capable of running more than one job by following these steps: