1828032 Members
1918 Online
109973 Solutions
New Discussion

JAVA and DCL

 
Willem Grooters
Honored Contributor

JAVA and DCL

As a spin-off of thread http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=611671
I'm just wondering if you can start a commandprocedure or program from within a JAVA application.

Willem
Willem Grooters
OpenVMS Developer & System Manager
9 REPLIES 9
Wim Van den Wyngaert
Honored Contributor

Re: JAVA and DCL

Willem Grooters
Honored Contributor

Re: JAVA and DCL

Wim,

Your example will surely work in Unix, but I'm not sure it will under VMS. Lets put it this way: I have my doubts:
Under Unix, each image is a process. Running another image from that image simply means: clone your process enviroment and execute the image in the clone. Afterwards, control can be returned.
Under VMS a process is much more: it's the complete user environment - resources, abilities....One implication is that within a the proces context, you can have one - and no more - image active at any time. When executing a java application, the active image is JAVA.EXE, implying you cannot start a second image within the same process. This means: as long as JAVA.EXE is active, NO OTHER process - not even DCL - can be active within that process, or you have to postpone the running image. (This is what happens if you ^Y, as long as you don't execute another image you can $CONTINUE - it's still in memory.)
What you can do from JAVA is either:
* SPAWN (the VMS way) which can allow return of control after image rundown,
* run the next command as a detached process,
* remove itself from memory before starting the next one (that is what LIB$DO_COMMAND does).

Both SPAWN and RUN/DETACHED may require synchronisation in some way to regain control by the JAVA application - and that might get quite complicated, since the advanced facilities of VMS are simply lacking in JAVA (since that's Unix))
DO_COMMAND inhibits return of control - since JAVA.EXE (and the application files) will be removed from memory.

Willem
Willem Grooters
OpenVMS Developer & System Manager
Craig A Berry
Honored Contributor

Re: JAVA and DCL

Let's look at the relevant line of the example Wim cites:

Process p = rn.exec("ls -als " + documenturl);

The exec() function is part of Java's Runtime class and is documented to be platform-dependent. However, the semantics are really the same as the CRTL's exec() function (which is very likely what gets invoked under the hood), so the call syntax is actually pretty much the same on any platform. On the other hand, the command you send is a native command, and on VMS, "ls" is more likely to invoke the language sensitive editor than it is to obtain a directory listing, and the "documenturl" may very well need to be converted to native file naming conventions.
Wim Van den Wyngaert
Honored Contributor

Re: JAVA and DCL

Willem,

Maybe you find something in
http://h18012.www1.hp.com/java/faq/
(just found it myself)

Wim
Wim
Martin P.J. Zinser
Honored Contributor

Re: JAVA and DCL

Hello Willem,

seems this at least was a serious problem:

http://h71000.www7.hp.com/wizard/wiz_6733.html

You might want to check the release notes if it is fixed by now.

Greetings, Martin
Wim Van den Wyngaert
Honored Contributor

Re: JAVA and DCL

Willem,

String env [ ] = {"a = 25"};
Process p = Runtime.getRuntime.exec ("test.com", env);
p.waitFor ( );

but it seems that the symbol a doesn't arrive well.

Also found
http://www.j2vms.co.uk/
It promisses the most ...

Wim
Wim
Willem Grooters
Honored Contributor

Re: JAVA and DCL

Thanks for the information so far.

Wim,
My impression now is I can start a command
procedure:

Process p = Runtime.getRuntime.exec ("test.com", env);

meaning I do NOT specify "@", just "test.com".
Which makes me believe that "run program.exe" would be possible also.

Your last link is promising as an extra. It's an impressive extension, but would render the Java program unusable on other platforms. (IMHO, I would then not use JAVA but create a native program)

Craig:
I know what "ls" means, in both Unix and VMS. That the command will actually do something different is quite obvious. The given command is not the issue, but the possibility to be able to run any program.

Martin:
Applies to 1.2.2 - but to other versions as well?

Willem
Willem Grooters
OpenVMS Developer & System Manager
Jan van den Ende
Honored Contributor

Re: JAVA and DCL

Willem,

I get the concept of leaving out the "@" sign.
How about parameter passing?
IIRC, the start of all this digging was how to trigger a system shutdown by a UPS using JAVA. AFAIK, that means it will be either interactive (defying the idea of triggering by a power fail to the UPS), or, the params will have to be passed to SHUTDOWN.COM

Jan
Don't rust yours pelled jacker to fine doll missed aches.
Willem Grooters
Honored Contributor

Re: JAVA and DCL

In the userguide for Java for VMS (1.4.2 version) I found a complete example on how to do this - including passing poarameters
Willem Grooters
OpenVMS Developer & System Manager