Java compiling with JZOS

General discussion on the JZOS batch launcher and toolkit
Post Reply
beinsargueix
Posts: 3
Joined: Tue Oct 03, 2006 2:49 am

Java compiling with JZOS

Post by beinsargueix »

Running z/OS140.
When i need to compile i used BPXBATCH as follow :
//JCOMP EXEC PGM=BPXBATCH,
// PARM='sh javac -d /u/einsarg/testjava/classes
// /u/einsarg/testjava/src/sample01.java'

:?: Can i do the same with JZOS....?

I tried the following, but doesn't work as i guess JZOS cannot execute shell commands :
//JAVA EXEC PROC=JVMPRC14,
// JAVACLS='javac'
//STDENV DD *
. /etc/profile
//MAINARGS DD *
-d /u/einsarg/testjava/classes
/u/einsarg/testjava/src/sample01.java'
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

JZOS can run java classes. The javac shell command is actually a way to launch java and run the "com.sun.tools.javac.Main" class. So you should be able to do compiles by using this as the class name.

Perhaps a better option would be to run Ant under JZOS and use the javac Ant task to do your compiles.

BTW - most people rarely if ever compile java on z/OS. It is much easier to compile on your workstation (say, under an IDE like Eclipse), package up jars and upload those jars to z/OS for execution. See the BatchSample project on the downloads page for a complete example, including Ant scripts that build and upload/deploy to z/OS.
beinsargueix
Posts: 3
Joined: Tue Oct 03, 2006 2:49 am

Post by beinsargueix »

hello,
Thanks for your answer.
I tried the following :
//JAVA EXEC PROC=JVMPRC14,
// JAVACLS='com.sun.tools.javac.Main'
//STDENV DD *
. /etc/profile
//MAINARGS DD *
'-d /u/einsarg/testjava/classes /u/einsarg/testjava/src/sample01.java'

:( and got :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2)
Classic VM (build 1.4.2, J2RE 1.4.2 IBM z/OS Persistent Reusable VM build
JVMJZBL1027I Using output encoding: IBM-1047
JVMJZBL1016I MVS commands are ENABLED
JVMJZBL1023N Invoking com.sun.tools.javac.Main.main()...
JVMJZBL2008E Could not find or load class: com.sun.tools.javac.Main
JVMJZBL2007E Stack trace follows:
java.lang.NoClassDefFoundError: com/sun/tools/javac/Main

Where is com.sun.tools.javac.Main class located...?
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

Try $JAVA_HOME/lib/tools.jar
beinsargueix
Posts: 3
Joined: Tue Oct 03, 2006 2:49 am

Post by beinsargueix »

Hello,
I have added $JAVA_HOME/lib/tools.jar to my CLASSPATH and it works perfectly.
Thanks. :lol:
Post Reply