In a STAX job, you can use a <process> element to run just about any
executable. To run a Java program, the process's <command> subelement
could contain 'java <ClassName>' and probably use the <env> sub-element to
add the Java class to the CLASSPATH). Just like when you run the 'java
<ClassName>' command at the command line, the class would need to be in
the CLASSPATH. Note that the environment in which the command is run is
STAFProc's environment (on the machine where the process is being run) so
if you are depending on the class already being in the CLASSPATH then it
must be in STAFProc's CLASSPATH environment variable (set before STAFProc
is started).
So, to run the STAFDemo, assuming it is located at
C:\STAF\samples\demo\STAFDemo.jar, you must have
"C:\STAF\samples\demo\STAFDemo.jar" in the CLASSPATH on the machine where
STAFDemo is run. You must also have the JSTAF.jar file in the CLASSPATH
(e.g. "C:\STAF\bin\JSTAF.jar") which is needed when running any Java
program that uses STAF APIs like the STAFDemo does. Note that the
JSTAF.jar file should already be in the CLASSPATH if you used
startSTAFProc.bat to start STAFProc. Then you can run "java
STAFDemoController" to start the STAFDemo. Note that the <process>
element will not complete until the process ends. So, since
STAFDemoController is a GUI program, it requires user input to run and to
be ended, so this means that the STAX job will not complete until you've
manually closed the STAFDemoController GUI. Here's a STAX job that runs
the STAFDemoController java program on the local system:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "stax.dtd">
<stax>
<defaultcall function="main"/>
<function name="main">
<sequence>
<process name="'Run STAF Demo'">
<location>'local'</location>
<command mode="'shell'">'java STAFDemoController'</command>
<env>'CLASSPATH=C:/STAF/samples/demo/STAFDemo.jar;{STAF/Env/CLASSPATH}'</env>
<stderr mode="'stdout'"/>
<returnstdout/>
</process>
<if expr="RC != 0">
<log message="1">
'Process Error: RC=%s, STAFResult=%s, STAXResult=%s' % \
(RC, STAFResult, STAXResult)
</log>
<else>
<log message="1">'Process RC was 0. STAXResult=%s' %
STAXResult</log>
</else>
</if>
</sequence>
</function>
</stax>
Note that you can learn more about STAF and STAX by reading the "Getting
Started with STAF" and "Getting Started wtih STAX" available via links on
the STAF/STAX documentation web page at
http://staf.sourceforge.net/docs.php. These guides provide examples like
this. This documentation web page also contains links for the "STAF
User's Guide" and the "STAX User's Guide" which contain even more
examples. Also, we provide education with hands-on exercises via links on
the "STAF/STAX Education" web page at
http://staf.sourceforge.net/education.php which also show how to do this.
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
From: Prabhat Saurabh <prabhat2...@gmail.com>
To: staf-users@lists.sourceforge.net,
Date: 07/09/2012 11:53 PM
Subject: [staf-users] Invoking a JAVA process through STAX...
Hello,
I am trying to invoke a JAVA process through STAX but as it acepts only
.xml files for process invocation, i am unable to invoke the JAVA process.
1. Can you suggest me how to invoke the JAVA class through stax for
monitoring purpose.
2. When i am running the STAFDempController, it is giving me an error as
"could not find or load main class STAFDemoController", could you suggest
me the solution for the same.
Thanks & Regards,
P R A B H A T.
Prabhat Saurabh | Associate Software Engineer |
InfoStretch Solutions Pvt. Ltd. | Elevating Confidence |
www.infostretch.com | Cell: +91 9325649321
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users