Calling Java Method from UNIX using shell script

Hi All,

I need to call a java method from a shell script. I know we can use the command
java ClassName
to call the main method in it. But I need to call another method that is there in the class and pass an email to it.

Can I use
java ClassName.MethodName(email)

Any help will be useful.

Thanks.

Yes..provided the CLASSPATH is properly set.
But passing the email body to a method depends how you written the method.

Thanks Dennis. But can you give me an example of how to call a method inside a java class and pass, say a number argument, from command line
Class name: testClass
Method inside testClass to be called: testMethod()
argument: testNumber

java testClass.testMethod(testNumber) ??

Thanks.

Try something like:

test.sh

 
export JAVA_HOME=<java home dir>
export CLASSPATH= <classpath>
NUMBER=$1;
$JAVA_HOME/bin/java testClass.testMethod($NUMBER)

sh test.sh 1232

This does not work. The compiler tries to find a class called testMethod inside testClass.
I get a NoClassDefFoundError for this.

Does anybody have a solution for this issue?