Page 1 of 1

Java program from goanywhere director

Posted: Mon Sep 26, 2011 12:45 pm
by satyatiwari
Does any body know if a java program be called from a project goanywhere director.

Re: Java program from goanywhere director

Posted: Thu Sep 29, 2011 8:54 am
by Support_Julie
It is possible to run Java programs that are native to the GoAnywhere host. Java class files are not executable. So, he would have to pass the class name as a parameter to the java executable. Since the host is System i (according to the case), there are actually a couple of ways he can do it. You can use Execute System i Command or Program (exec400) task or the generic Execute Native Command (exec) task.

Using the first approach, (iSeries specific), he would have to run something similar to the following command:

JAVA CLASS(HelloWorld) CLASSPATH('/MyDir')

In the above HelloWorld is the name of the Java class he wants to run. This class must have a main method. The class path tells where this class and any other classes/Jar files this class depends on. More paths can be added by separating each class path with a colon. For more information refer to the help panels on the command.

The second approach (generic and platform independent):

The executable to run would be /path/to/java. For example, /QOpenSys/QIBM/ProdData/JavaVM/jdk50/32bit/jre/bin/java.
Then he needs to have one or more parameters to specify the class path and the class to run. It is just similar to how one would run a Java program. Each token needs to be added as an argument under the exec task. For example the first argument should be -cp, then the second one should be the actual class path, then the third one should the name of the class without the ".class" extension.