When I want to run a java class from Windows command line, I create a cmd
file which looks like that :
echo %date% %time% log beginning of myprogram >>c:\mydirectory\log.txt
echo %date% %time% log end of myprogram>>c:\adtraxion\log.txt
You have to put in the -classpath the path to all jars you use in your
classes (yes, the long names...), and the path to the directory where the
class you want to run is.
Note that when you use directories with blanks in the name, such as
program files, you have to replace each blank by two double quotes : ""
In the example above, I use rt.jar, mysql-connector-....jar, and my class
I want to run is in c:\mydirectory\classes.
Each jar path and each class path are separated by a semicolon.
Of course, if you want to run the same class using the same jars on a
regular basis, then you can add the classpath to your pc settings.
For running your class on your iSeries, it's basically the same.
Create a CL with such a command :
Each jar path and class path is separated by a colon.
In the example above, I've copied all jars I need in /homepgm/jar_applis
directory in the IFS.
Walden H. Leverich wrote:
I'm building a test java app to consume a web service. Building it
wasn't that hard*, and it runs fine in the IDE, however I now want to
run it from the command line (windows). How do I set the classpath? Or
to put it another way, what do I need to put into the classpath?
I know I can set the path on the java command and/or in an environment
variable, but what do I need to put there? Adding the webservice client
in WDSC auto-added axis, commons-discovery, jaxrpc, saak, wsdl4j and
commons-logging, but each with a nice long name, and it added them
inside the IDE.
What do I need to include in the command-line classpath to run my java
class on Windows? Then, what will I need to include to run it on i5/OS?
*Harder than I would have thought, but I'll write that off to my knowing
how to do it in .NET, and being a novice in Java.