Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Running a Java program in the background

SOLVED
Go to solution
OwensJ
Advisor

Running a Java program in the background

I have a java program that needs to run continuously on OpenVMS. I can run it just fine manually in a terminal window by typing first
@sys$common:[java$60.com]java$60_setup.com
and then
java -jar MyProgram.jar

The problem of course is that the program only runs as long as the terminal window is open. I am not that familiar with OpenVMS, but from what I have read it would seem to fall under the realm of the SUBMIT command.

Basically I want to be able to run the "java -jar MyProgram.jar" in the background and keep it running forever. Also, the "java" command doesn't run without the environment command being run first. So what would I need to do in OpenVMS to accomplish say running this program at startup and keeping it running?
3 REPLIES
Joseph Huber_1
Honored Contributor
Solution

Re: Running a Java program in the background

Put the commands to setup and run the java program in a DCL command-file, say runmyjava.com:

$@sys$common:[java$60.com]java$60_setup.com
$ java -jar MyProgram.jar

and then submit it from sys$manager:systartup_vms.com like

$ submit/noprint runmyjava
or
$ submit/noprint/user=me disk$user:[me]runmyjava

But be aware: the java program must not do any graphic (X11) operations, unless You create a presistent Xwindows display, and set the batch procedures display to it before starting the java program.
http://www.mpp.mpg.de/~huber
OwensJ
Advisor

Re: Running a Java program in the background

Thanks Joseph,

I ended up doing almost exactly what you said. I found an old thread that showed me some similar stuff too (Thanks to Rick Retterer there as well). I created a .COM file which works great and am looking to just change it using a submit command instead of a run/detach command like I found in that thread.

http://h30499.www3.hp.com/t5/System-Management/start-a-process/m-p/4510831#M25351


I'm going to combine both of your suggestions. Thanks again!

OwensJ
Advisor

Re: Running a Java program in the background

I did the following:

(I'm showing example in a generic format without document code)

made a myapp.com file, which actually executes my java program containing the following:
$ set NoOn
$ write sys$output "Java process starting..."
$ @sys%common:[java$60.com]java$60_setup.com
$! define java$classpath here if necessary
$! show log java$classpath
$ set def sys$common:[myappdir]
$ java -jar MyApp.jar
$ write sys$output "Java process exiting..."
$ exit

and then created a myapp_startup.com file to run the process as a batch process in the background: (which puts it in a batch queue i created)
$ Node_Name = F$GetSYI ( "NodeName" )
$ If F$Search ("sys$common:[myappdir]myapp.com" ) .nes. ""
$ Then
$ Log_file = "sys$common:[myappdir]''Node_Name'_myapp.log"
$ Submit/Notify/Noprint/Log="Log_File'/USER=SYSTEM -
/Queue='Node_Name'$Batch sys$common:[myappdir]myapp.com
$ EndIf
$ Exit

This runs my app in the background inside of a batch queue, which can be monitored by a show sys/b command