× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Walden,

When I want to run a java class from Windows command line, I create a cmd
file which looks like that :

REM myprogram.cmd
echo on
set
echo %date% %time% log beginning of myprogram >>c:\mydirectory\log.txt
java -classpath
C:\Program""Files\Java\jre1.5.0_09\lib\rt.jar;C:\mydirectory\classes\mysql-connector-java-3.1.13-bin.jar;C:\mydirectory\classes;
package.subpackageifexist.MyClass
echo %date% %time% log end of myprogram>>c:\adtraxion\log.txt
REM exit
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 :

RUNJVA CLASS(ifsdirectorywhereyourclassis.subdirectoryifexists.Classname)
+

CLASSPATH('/ifsdirectorywhereyourclassis/subdirectoryifexists:+
/homepgm/jar_applis/axis.jar:+
/homepgm/jar_applis/axis-ant.jar:+
/homepgm/jar_applis/jaxrpc.jar:+
/homepgm/jar_applis/xerces.jar:+
/homepgm/jar_applis/commons-logging-1.0.4.jar:+
/homepgm/jar_applis/commons-discovery-0.2.jar:+
/homepgm/jar_applis/log4j-1.2.8.jar:+
/homepgm/jar_applis/saaj.jar:+
/homepgm/jar_applis/wsdl4j-1.5.1.jar:+
')

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.

Marie-Line

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?



Thanks,

-Walden



*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.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.