java in batch



Support for Java SE, EE & ME, JVM, JNI, JDBC, EJB, JFC, JPDA, JAAS,JCE, JAXP, XML and Java API.

java in batch

Postby jaggz » Sun May 22, 2011 8:00 am

Hi group,

I was trying to invoke a java executable file using the below batch but The expected output was not recieved. The out out was expected to throw as "HELLO WORLD" but there was no luck.

My JCL :

//A255209$ JOB MSGCLASS=X,MSGLEVEL=(1,1),CLASS=B,
// REGION=5M,NOTIFY=&SYSUID
//* -------------------------------------------------
//* Run java program
//* -------------------------------------------------
//RUN EXEC PGM=BPXBATCH,
// PARM='SH java -cp /proj2/jproj/path.classpath'
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//STDOUT DD PATH='/proj2/jproj/java.stdout',
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
// PATHMODE=SIRWXU
//STDERR DD PATH='/proj2/jproj/java.stderr',
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
// PATHMODE=SIRWXU
//STDENV DD *
PATH=/bin
JAVA_HOME=/usr/lpp/java1.5/J5.0_64
/*
//COPYOUT EXEC PGM=IKJEFT01,DYNAMNBR=300,COND=EVEN
//SYSTSPRT DD SYSOUT=*
//HFSOUT DD PATH='/proj2/jproj/java.stdout'
//HFSERR DD PATH='/proj2/jproj/java.stderr'
//STDOUTL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=133,BLKSIZE=137)
//STDERRL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=133,BLKSIZE=137)
//SYSPRINT DD SYSOUT=*
//SYSTSIN DD DATA,DLM='/>'
ocopy indd(HFSOUT) outdd(STDOUTL)
ocopy indd(HFSERR) outdd(STDERRL)
/>

JESMSGLG :

J E S 2 J O B L O G -- S Y S T E M Z O S B -- N O D E N 1

---- SATURDAY, 21 MAY 2011 ----
IRR010I USERID IBMUSER IS ASSIGNED TO THIS JOB.
ICH70001I IBMUSER LAST ACCESS AT 07:22:18 ON SATURDAY, MAY 21, 2011
$HASP373 A255209$ STARTED - INIT 5 - CLASS B - SYS ZOSB
IEF403I A255209$ - STARTED - TIME=07.22.19
- --TIMINGS (MINS.)-- -
-STEPNAME PROCSTEP RC EXCP CONN TCB SRB CLOCK SERV WORKLOAD P
-RUN 00 66 14 .00 .00 .0 293 BATCH
-*OMVSEX 00 23 6 .00 .00 .0 67 BATCH
-*OMVSEX 01 144 4 .00 .00 .3 200 BATCH
-COPYOUT 00 68 31 .00 .00 .0 694 BATCH
IEF404I A255209$ - ENDED - TIME=07.22.46
-A255209$ ENDED. NAME- TOTAL TCB CPU TIME= .00 TOTAL EL
$HASP395 A255209$ ENDED
ATISTICS ------
EXECUTION DATE
2011 JOB EXECUTION DATE
30 CARDS READ
126 SYSOUT PRINT RECORDS
0 SYSOUT PUNCH RECORDS
7 SYSOUT SPOOL KBYTES
0.46 MINUTES EXECUTION TIME


JESYSMSG :
ICH70001I IBMUSER LAST ACCESS AT 07:22:18 ON SATURDAY, MAY 21, 2011
IEF236I ALLOC. FOR A255209$ RUN
IEF237I JES2 ALLOCATED TO SYSPRINT
IEF237I JES2 ALLOCATED TO SYSOUT
IGD103I SMS ALLOCATED TO DDNAME STDOUT
IGD103I SMS ALLOCATED TO DDNAME STDERR
IEF237I JES2 ALLOCATED TO STDENV
IEF142I A255209$ RUN - STEP WAS EXECUTED - COND CODE 0000
IEF285I IBMUSER.A255209$.JOB07223.D0000103.? SYSOUT
IEF285I IBMUSER.A255209$.JOB07223.D0000104.? SYSOUT
IGD104I HFS FILE WAS RETAINED, DDNAME IS (STDOUT )
FILENAME IS (/proj2/jproj/java.stdout)
IGD104I HFS FILE WAS RETAINED, DDNAME IS (STDERR )
FILENAME IS (/proj2/jproj/java.stderr)
IEF285I IBMUSER.A255209$.JOB07223.D0000101.? SYSIN
IEF373I STEP/RUN /START 2011141.0722
IEF374I STEP/RUN /STOP 2011141.0722 CPU 0MIN 00.03SEC SRB 0MIN 00.00S
IEF142I A255209$ *OMVSEX - STEP WAS EXECUTED - COND CODE 0000
IEF142I A255209$ *OMVSEX - STEP WAS EXECUTED - COND CODE 0000
IEF373I STEP/*OMVSEX /START 2011141.0722
IEF374I STEP/*OMVSEX /STOP 2011141.0722 CPU 0MIN 00.01SEC SRB 0MIN 00.00S
IEF142I A255209$ *OMVSEX - STEP WAS EXECUTED - COND CODE 0001
IEF373I STEP/*OMVSEX /START 2011141.0722
IEF374I STEP/*OMVSEX /STOP 2011141.0722 CPU 0MIN 00.02SEC SRB 0MIN 00.00S
IEF236I ALLOC. FOR A255209$ COPYOUT
IEF237I JES2 ALLOCATED TO SYSTSPRT
IGD103I SMS ALLOCATED TO DDNAME HFSOUT
IGD103I SMS ALLOCATED TO DDNAME HFSERR
IEF237I JES2 ALLOCATED TO STDOUTL
IEF237I JES2 ALLOCATED TO STDERRL
IEF237I JES2 ALLOCATED TO SYSPRINT
IEF237I JES2 ALLOCATED TO SYSTSIN
IEF142I A255209$ COPYOUT - STEP WAS EXECUTED - COND CODE 0000
IEF285I IBMUSER.A255209$.JOB07223.D0000105.? SYSOUT
IGD104I HFS FILE WAS RETAINED, DDNAME IS (HFSOUT )
FILENAME IS (/proj2/jproj/java.stdout)
IGD104I HFS FILE WAS RETAINED, DDNAME IS (HFSERR )
IGD104I HFS FILE WAS RETAINED, DDNAME IS (HFSERR )
FILENAME IS (/proj2/jproj/java.stderr)
IEF285I IBMUSER.A255209$.JOB07223.D0000106.? SYSOUT
IEF285I IBMUSER.A255209$.JOB07223.D0000107.? SYSOUT
IEF285I IBMUSER.A255209$.JOB07223.D0000108.? SYSOUT
IEF285I IBMUSER.A255209$.JOB07223.D0000102.? SYSIN
IEF373I STEP/COPYOUT /START 2011141.0722
IEF374I STEP/COPYOUT /STOP 2011141.0722 CPU 0MIN 00.08SEC SRB 0MIN 00.00S
IEF375I JOB/A255209$/START 2011141.0722
IEF376I JOB/A255209$/STOP 2011141.0722 CPU 0MIN 00.14SEC SRB 0MIN 00.00S

SYSTSPRT :

READY
ocopy indd(HFSOUT) outdd(STDOUTL)
READY
ocopy indd(HFSERR) outdd(STDERRL)
READY
END

STDOUTL :


Usage: java Ý-options¨ class Ýargs...¨
(to execute a class)
or java Ý-jar¨ Ý-options¨ jarfile Ýargs...¨
(to execute a jar file)

where options include:
-cp -classpath <directories and zip/jar files separated by :>
set search path for application classes and resources
-D<name>=<value>
set a system property
-verboseÝ:class|gc|jni¨
enable verbose output
-version print product version
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-agentlib:<libname>Ý=<options>¨
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>Ý=<options>¨
load native agent library by full pathname
-javaagent:<jarpath>Ý=<options>¨
load Java programming language agent, see java.lang.instrument
-? -help print this help message
-X print help on non-standard options
-assert print help on assert options


Could Anyone please throw some light on this issue.

Also, i have implemented the JZOS tool kit to run this java codes but the manuals are not still clear about mentioning the JAVACLS parameters.

Regards,
Jaggz
User avatar
jaggz
 
Posts: 356
Joined: Fri Jul 23, 2010 8:51 pm
Has thanked: 8 times
Been thanked: 5 times

Re: java in batch

 

Re: java in batch

Postby Robert Sample » Sun May 22, 2011 8:24 am

The system is telling you, quite clearly, what is wrong:
STDOUTL :


Usage: java Ý-options¨ class Ýargs...¨
(to execute a class)
or java Ý-jar¨ Ý-options¨ jarfile Ýargs...¨
(to execute a jar file)
compared to
//RUN EXEC PGM=BPXBATCH,
// PARM='SH java -cp /proj2/jproj/path.classpath'
Since you did not provide any Java program for the system to execute, it did not execute any Java program. Did you compile your program with JAVAC? If so, and your command was javac HelloWorld (for example), you should execute
]//RUN EXEC PGM=BPXBATCH,
// PARM='SH java HelloWorld'
or possibly
]//RUN EXEC PGM=BPXBATCH,
// PARM='SH java /proj2/jproj/HelloWorld'
but I'd try without the full path first.
Robert Sample
Global moderator
 
Posts: 3579
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 259 times

Re: java in batch

Postby jaggz » Sun May 22, 2011 4:44 pm

Hi Robert,

Thanks for the reply. I tried with the given codes but i got as java class "helloworld" not found and also with second code i got an error as javaclass .proj2.jproj.helloworld' not found. The path i have ftped the java developed codes within OMVS was /proj/jproj/path.classpath and it was not a jar file but it was a classpath file. To run this file are there any constraint ? but the path.classpath file contains the codes for throwing the message as "Hello world"
User avatar
jaggz
 
Posts: 356
Joined: Fri Jul 23, 2010 8:51 pm
Has thanked: 8 times
Been thanked: 5 times

Re: java in batch

Postby Robert Sample » Sun May 22, 2011 7:23 pm

If your code is stored as helloworld.java, when compiled it becomes helloworld.class and you would therefore issue the command java helloworld to execute the code. I have compiled and executed a number of Java programs using this method. I have never run across anything like "path.classpath" -- class paths are exported in Unix System Services by issuing the export command in your .profile or directly after getting into Unix System Services.

Have you tested in Unix System Services? If not, testing by directly issuing the commands from a Unix System Services prompt will speed up your debugging process by allowing you to make sure the commands work before attempting to use them in batch.
Robert Sample
Global moderator
 
Posts: 3579
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 259 times

Re: java in batch

Postby jaggz » Mon May 23, 2011 6:04 pm

Hi Robert,

I directly executed the command java Hellow.class but i got the below error message :

$ java Hellow.class
The java class could not be loaded. java.lang.ClassFormatError: (Hellow) bad mag
ic number at offset=0
$


Also I gave java Hellow command and i got an error message as : java class not found : Hellow.

Please guide me in this regard.

Regards,
Jaggz
User avatar
jaggz
 
Posts: 356
Joined: Fri Jul 23, 2010 8:51 pm
Has thanked: 8 times
Been thanked: 5 times

Re: java in batch

Postby Robert Sample » Mon May 23, 2011 7:05 pm

I strongly recommend you start with the basics. It appears your file transfer of the java class failed to transfer a valid java class file for some reason, since the message seems to indicate the class file is not valid. Something like this (in OMVS or via Telnet into the Unix System Services port) should help you confirm what you're trying to do:
TTSSRS0:/u/tech/ttssrs0: >cat HelloWorld.java
class HelloWorld {
      public static void main(String arg--) {
          System.out.println("Hello world from Java.");
      }
}
TTSSRS0:/u/tech/ttssrs0: >javac HelloWorld.java
TTSSRS0:/u/tech/ttssrs0: >java HelloWorld
Hello world from Java.
TTSSRS0:/u/tech/ttssrs0: >ls -al HelloWorld.*
--rwxrwxrwx   1 OMVS     UTEC100      436 May 23 09:25 HelloWorld.class
--rwxrwxrwx   1 OMVS     UTEC100      131 Mar 10  2001 HelloWorld.java
TTSSRS0:/u/tech/ttssrs0: >
Once you have successfully been able to do this, then you can look at doing the same via a batch job, then look at the file transfer and so forth. I do not know if java bytecode needs a binary or text transfer -- if you don't know either then that is one key thing you MUST find out. But unless you have successfully tested java interactively, then doing the same thing in a batch job, you will not be able to tell if your problem is a java problem, a JCL problem, a Unix System Services problem, a file transfer problem, or something else.
Robert Sample
Global moderator
 
Posts: 3579
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 259 times

Re: java in batch

Postby jaggz » Sat Jun 18, 2011 8:16 am

I was able to execute directly in tso omvs. But while executing througH jcl We got the below error.

JCL :
000001 //U266015A JOB ,,CLASS=A,MSGCLASS=C,
000002 // MSGLEVEL=(1,1),NOTIFY=&SYSUID
000003 //RUN EXEC PGM=BPXBATCH,
000004 // PARM='SH java -jar /sds/U266015/FabFinCG.jar SDS 2011-01-01
000005 // 2011-12-31'
000006 //SYSPRINT DD SYSOUT=*
000007 //SYSOUT DD SYSOUT=*
000008 //STDOUT DD PATH='/sds/U266015/java.stdout',
000009 // PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
000010 // PATHMODE=SIRWXU
000011 //STDERR DD PATH='/sds/U266015/java.stderr',
000012 // PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
000013 // PATHMODE=SIRWXU
000014 //STDENV DD *
000015 CLASSPATH='/sds/U266015/FabFinCG.jar'
000016 //COPYOUT EXEC PGM=IKJEFT01,DYNAMNBR=300,COND=EVEN
000017 //SYSTSPRT DD SYSOUT=*
000018 //HFSOUT DD PATH='/sds/U266015/java.stdout'
000019 //HFSERR DD PATH='/sds/U266015/java.stderr'
000020 //STDOUTL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=133,BLKSIZE=137)
000021 //STDERRL DD SYSOUT=*,DCB=(RECFM=VB,LRECL=133,BLKSIZE=137)
000022 //SYSPRINT DD SYSOUT=*
000023 //SYSTSIN DD DATA,DLM='/>'
000024 ocopy indd(HFSOUT) outdd(STDOUTL)
000025 ocopy indd(HFSERR) outdd(STDERRL)
000026 />

JESMSGLG


17.51.04 JOB03311 ---- FRIDAY, 17 JUN 2011 ----
17.51.04 JOB03311 IRR010I USERID U266015 IS ASSIGNED TO THIS JOB.
17.51.04 JOB03311 ICH70001I U266015 LAST ACCESS AT 17:31:51 ON FRIDAY, JUNE 17
17.51.04 JOB03311 $HASP373 U266015A STARTED - INIT 3 - CLASS A - SYS CTS2
17.51.05 JOB03311 - --TIMINGS (MIN
17.51.05 JOB03311 -STEPNAME PROCSTEP RC EXCP CONN TCB SRB CLOCK
17.51.05 JOB03311 -RUN 00 64 12 .00 .00 .0
17.51.05 JOB03311 -*OMVSEX 00 27 6 .00 .00 .0
17.51.08 JOB03311 -*OMVSEX 01 157 4 .00 .00 .0
17.51.08 JOB03311 -COPYOUT 00 79 29 .00 .00 .0
17.51.08 JOB03311 -U266015A ENDED. NAME- TOTAL TCB CPU TIM
17.51.08 JOB03311 $HASP395 U266015A ENDED
------ JES2 JOB STATISTICS ------
17 JUN 2011 JOB EXECUTION DATE
26 CARDS READ
105 SYSOUT PRINT RECORDS
0 SYSOUT PUNCH RECORDS
7 SYSOUT SPOOL KBYTES
0.07 MINUTES EXECUTION TIME


JESSYSMSG

ICH70001I U266015 LAST ACCESS AT 17:31:51 ON FRIDAY, JUNE 17, 2011
IEF236I ALLOC. FOR U266015A RUN
IEF237I JES2 ALLOCATED TO SYSPRINT
IEF237I JES2 ALLOCATED TO SYSOUT
IGD103I SMS ALLOCATED TO DDNAME STDOUT
IGD103I SMS ALLOCATED TO DDNAME STDERR
IEF237I JES2 ALLOCATED TO STDENV
IEF142I U266015A RUN - STEP WAS EXECUTED - COND CODE 0000
IEF285I U266015.U266015A.JOB03311.D0000103.? SYSOUT
IEF285I U266015.U266015A.JOB03311.D0000104.? SYSOUT
IGD104I HFS FILE WAS RETAINED, DDNAME IS (STDOUT )
FILENAME IS (/sds/U266015/java.stdout)
IGD104I HFS FILE WAS RETAINED, DDNAME IS (STDERR )
FILENAME IS (/sds/U266015/java.stderr)
IEF285I U266015.U266015A.JOB03311.D0000101.? SYSIN
IEF373I STEP/RUN /START 2011168.1751
IEF374I STEP/RUN /STOP 2011168.1751 CPU 0MIN 00.02SEC SRB 0MIN 00.00S
IEF142I U266015A *OMVSEX - STEP WAS EXECUTED - COND CODE 0000
IEF373I STEP/*OMVSEX /START 2011168.1751
IEF374I STEP/*OMVSEX /STOP 2011168.1751 CPU 0MIN 00.02SEC SRB 0MIN 00.00S
IEF142I U266015A *OMVSEX - STEP WAS EXECUTED - COND CODE 0001
IEF373I STEP/*OMVSEX /START 2011168.1751
IEF374I STEP/*OMVSEX /STOP 2011168.1751 CPU 0MIN 00.04SEC SRB 0MIN 00.00S
IEF236I ALLOC. FOR U266015A COPYOUT
IEF237I JES2 ALLOCATED TO SYSTSPRT
IGD103I SMS ALLOCATED TO DDNAME HFSOUT
IGD103I SMS ALLOCATED TO DDNAME HFSERR
IEF237I JES2 ALLOCATED TO STDOUTL
IEF237I JES2 ALLOCATED TO STDERRL
IEF237I JES2 ALLOCATED TO SYSPRINT
IEF237I JES2 ALLOCATED TO SYSTSIN
IEF142I U266015A COPYOUT - STEP WAS EXECUTED - COND CODE 0000
IEF285I U266015.U266015A.JOB03311.D0000105.? SYSOUT
IGD104I HFS FILE WAS RETAINED, DDNAME IS (HFSOUT )
FILENAME IS (/sds/U266015/java.stdout)
IGD104I HFS FILE WAS RETAINED, DDNAME IS (HFSERR )
FILENAME IS (/sds/U266015/java.stderr)
IEF285I U266015.U266015A.JOB03311.D0000106.? SYSOUT
IEF285I U266015.U266015A.JOB03311.D0000107.? SYSOUT
IEF285I U266015.U266015A.JOB03311.D0000108.? SYSOUT
IEF285I U266015.U266015A.JOB03311.D0000102.? SYSIN
IEF373I STEP/COPYOUT /START 2011168.1751
IEF374I STEP/COPYOUT /STOP 2011168.1751 CPU 0MIN 00.07SEC SRB 0MIN 00.00S
IEF375I JOB/U266015A/START 2011168.1751
IEF376I JOB/U266015A/STOP 2011168.1751 CPU 0MIN 00.15SEC SRB 0MIN 00.00S

SYSTSPRT
READY
ocopy indd(HFSOUT) outdd(STDOUTL)
READY
ocopy indd(HFSERR) outdd(STDERRL)
READY
END

STDERRL

Error: unable to allocate 67108864 bytes for GC in j9vmem_reserve_memory.
Error: unable to allocate 53686784 bytes for GC in j9vmem_reserve_memory.
Error: unable to allocate 42949120 bytes for GC in j9vmem_reserve_memory.
Error: unable to allocate 34359296 bytes for GC in j9vmem_reserve_memory.
Error: unable to allocate 27487232 bytes for GC in j9vmem_reserve_memory.
Error: unable to allocate 21989376 bytes for GC in j9vmem_reserve_memory.
Error: unable to allocate 17591296 bytes for GC in j9vmem_reserve_memory.
Error: unable to allocate 14072832 bytes for GC in j9vmem_reserve_memory.
JVMJ9VM015W Initialization error for library j9jit23(11): cannot initialize JIT
Could not create the Java virtual machine.


TSO OMVS :

# df -kP .
Filesystem 1024-blocks Used Available Capacity Mounted on
OMVS.SDS 50400 42748 7272 86% /sds/U266015



When executed my admininistrators id they got the STDERRL as

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
at java.lang.reflect.Method.invoke(Method.java:618)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.jav
Caused by: java.lang.NoClassDefFoundError: org.springframework.batch.core.launch
at biz.geos.fatca.batch.MainFabFinCGBatch.main(MainFabFinCGBatch.java:74)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.springframework.batch.core.laun
at java.net.URLClassLoader.findClass(URLClassLoader.java:496)
at java.lang.ClassLoader.loadClass(ClassLoader.java:631)
at java.lang.ClassLoader.loadClass(ClassLoader.java:597)

Could you please suggest some idea or guidelines
User avatar
jaggz
 
Posts: 356
Joined: Fri Jul 23, 2010 8:51 pm
Has thanked: 8 times
Been thanked: 5 times

Re: java in batch

Postby Robert Sample » Sat Jun 18, 2011 6:17 pm

Java requires some parameters in the BPXPRMxx member of SYS1.PARMLIB to be much larger than the defaults IBM provides. You need to contact your site support group and have them adjust the BPXPRMxx member values to allow enough memory for Java to execute. If they have already done this, they will need to open a PMR with IBM to get your problem resolved.

This is NOT an issue an application person can fix -- it must be done by systems support people.
Robert Sample
Global moderator
 
Posts: 3579
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 259 times


Return to Mainframe Java

 


  • Related topics
    Replies
    Views
    Last post