How to run a java program in a specific subsystem in AS400

How to do it? I saw this question: How to add job in Subsystem in as400 The person who asked had this process:

Creating Subsystem (SBS):

Create JOBQ:

Add JOBQ entry in subsystem

Submit PWI job in this JOBQ

Start Subsystem


And I tried something similar, but indeed, the job completes immidiately and you can't see java running (because it does not), even if you have a java program with an infinite loop. The person who asked said " had created class and added for this job and added routing entry. Problem Solved" Can someone please explain how to do that? If it is possible,with some concepts related to understand why. I coulndt figure it out using the documentation. Thanks.


  • I see what you are talking about now. IBM i is quite flexible and user configurable, but with this flexibility comes additional complexity. You did not create all the objects you needed to create a subsystem. If you want a subsystem just to run Java jobs in batch, you need to do a little more work.

    • First you need a subsystem description: MYSBS (you have that)
    • Next you need a way to get jobs into the subsystem, that is a job queue: MYJOBQ (you have that)
    • Finally you need to give the subsystem a way to process the request messages coming from the job queue, this is a routing entry: (you don't have that)

    So take a look at subsystem QSYS/QBATCH. (DSPSBSD)

    DSPSBSD Screen

    Menu options 1 and 2 were taken care of with the CRTSBSD command. 3, 4, and 5 are empty. 6 is taken care of with the ADDJOBQE command, 7 has some stuff in it, and 8 - 10 are also empty.

    This is the minimum configuration to make a batch subsystem work. Without the routing entries, the subsystem monitor does not know what to do with the request messages on the job queue. Thus, nothing happens.

    If you have a typical system, the routing entries in QBATCH are:

    QBATCH Routing Entries

    I'm not sure what the first one does, but the second one runs S36 jobs, the third one runs S38 jobs, and the fourth one runs everything else (IBM i jobs). It's the compare data that selects which routing entry to use. If you prompt the SBMJOB command, then press F10 to see additional parameters, on the second page of the parameter list, you will see this:

    SBMJOB Additional Parameters

    That routing data is compared to the compare value in the routing entries in order from top to bottom. The first match it gets is the routing entry the subsystem monitor chooses. In this case QCMDB does not match any of the compare data strings, so the last routing entry, the one with *ANY, will be selected. Notice that each routing entry points to a program and library. That is the program that the subsystem monitor calls to process the job queue entry.

    Best thing to do is duplicate those 4 routing entries, but not completely. If you look at the details, each routing entry points to a class named the same as the subsystem description. So the easiest thing to do is to duplicate class QSYS/QBATCH and name it MYSBS using the CRTCLS command. Then when you add the four routing entries just leave the default class *SBSD.

    But, you can probably get away with just creating the last routing entry if you won't be executing S36, S38, or QIGC (whatever that is) jobs in this subsystem. The routing entries are added using ADDRTGE. Note, that if you do this, you won't be able to run S38 jobs in this subsystem, but S36EVOKE and QIGC jobs use the same command processer as IBM i, that is QSYS/QCMD, so they may still work properly.

    In each case, routing entry or class, model your new ones after the ones in the QSYS/QBATCH subsystem, and always include the last catch all routing entry. Otherwise, the new subsystem won't do anything.