Detect JZOS availability

General discussion on the JZOS batch launcher and toolkit
Post Reply
tfull
Posts: 15
Joined: Mon Oct 10, 2005 4:27 pm

Detect JZOS availability

Post by tfull »

I have a java app that might run under z/OS or elsewhere. I'd like to do a WTO when the service comes active on z/OS, but need to bypass it if I'm on another platform. I'm trying to do something like:

boolean jzosAvailable = true;
try {
Class.forName("com.ibm.jzos.MvsConsole", false, this.getClass().getClassLoader());
} catch (ClassNotFoundException e) {
jzosAvailable = false;
}
if (jzosAvailable) {
try {
MvsConsole.wto(message,
0x0020, // routecde
0x4000); // descriptor code
} catch (UnsatisfiedLinkError e) { // missing c piece. catch and dispose of silently
}
}

I have the jzos jar available in my eclipse workspace to make it easier to edit code, so the first load works ok, but I get an UnsatisfiedLinkError when running outside z/OS. I tried adding the catch, but the error is not percolating back to me so I can't handle it. I've also tried

boolean jzosAvailable = true;
try {
Class.forName("com.ibm.jzos.MvsConsole", false, this.getClass().getClassLoader());
System.loadlibrary("jzos");
} catch (ClassNotFoundException | UnsatisfiedLinkError e) {
jzosAvailable = false;
}
if (jzosAvailable) {
MvsConsole.wto(message,
0x0020, // routecde
0x4000); // descriptor code
}

That fixes the distributed side, but now my WTO stops working.

Any easy way to make sure JZOS is all in place on the platform so it can be used or bypassed accordingly?
tfull
Posts: 15
Joined: Mon Oct 10, 2005 4:27 pm

Re: Detect JZOS availability

Post by tfull »

I used a different method. It makes an assumption that when on z/OS, everything is place, so might be have an error, but it seems to work.
String os = System.getProperty("os.name");
LOG.info(os);
if (os.equals("z/OS")) {
MvsConsole.wto(message,
0x0020, // routecde
0x4000); // descriptor code
}
Post Reply