Problem:
Programs that accept data from command line return different results when run from cobrun or cobjrun.
ex. cobrun proga parm1
With cobrun, 'parm1' is returned when doing an ACCEPT ws-var FROM COMMAND-LINE.
with cobjrun, 'proga parm1' is returned instead.
Resolution:
This is the expected behavior...The problem is that when using cobrun, the command line is being passed directly to the COBOL run-time system. When using cobjrun, the command line is passed to the JAVA Virtual Machine. In this case, the JVM turns around and creates a new command line to invoke the COBOL run-time system.
When using cobrun, argument 0 is the program name itself and your command line parameters start with argument 1 to argument n...
When using cobjrun, argument 0 becomes the cobrun command inserted there by the JVM to invoke your COBOL program, argument 1 becomes the program name and your command line parameters start with argument 2 to argument n...
There is no way to get around this, the way you access parameters will need to be changed.
If you want to get rid of the program name, Instead of using ACCEPT FROM COMMAND-LINE, you could use ACCEPT FROM ARGUMENT-VALUE.
You would do the following:
DISPLAY 2 UPON ARGUMENT-NUMBER (this is to tell it you want argument 2)
ACCEPT ws-var2 FROM ARGUMENT-VALUE
If you have additional parameters on the command line, you can then
DISPLAY 3 UPON ARGUMENT-NUMBER
ACCEPT ws-var3 FROM ARGUMENT-VALUE
And so forth for all parameters...