When using call "system" to start a a new process from a JVM COBOL program, ACCEPT and DISPLAY statements in the new process do not work.
The JVM runtime uses the underlying support in Java’s Process class which is written to be portable etc. This has the side effect than on Unix/Linux the support it has no notion of terminal I/O.
So, this means that you can’t use CALL “system” in JVM where the new process is doing terminal i/o. However there is a work-around. You can use xterm –e to start a new X-term window and run a script. For example, here is a demo where test1.cbl calls a script, runs2.sh. The script set-ups the environment needed for cobjrun. This is required due to a Unix/Linux security feature which prevents spawned processes from inheriting the LD_LIBRARY_PATH.
For the demo both test1.cbl and test2.cbl were compiled with cob –j. To run use cobjrun test1.
01 ws-runit-id pic x(8) comp-5.
01 ws-stack pic x(4) comp-5.
01 ws-flags pic x(4) comp-5 value 1.
01 ws-status pic x(4) comp-5.
display "in test 1"
call "system" using z"xterm -e /runs2.sh"
display "back in test 1"
01 ws-key pic x.
display "in test 2 - press a key"
display "you pressed " ws-key
NOTE – The DISPLAY environment variable needs to be set to an X-Windows server. If running a terminal emulator from Windows you will require an X-Windows server running on the PC to allow the new window to be created on the PC’s screen.
When you run the demo, test1 uses the main terminal window. When the runs2.sh script is run a new window is created and all accept and display i-o in test2.cbl goes to the new window. When test2 terminates, the window is destroyed and test1 continues in the original terminal window.
The xterm command takes lots of parameters which allow you to configure the look and feel of the new window.