I have a jar file with 2 classes class A and class B and each of them has a main method.
I want to create two separate shell scripts to call each one of them. Script 1 for class A and script 2 for class B. In each script I need to do the following:
- Call the particular class and pass arguments to its main method
args[0] - The passed arguments should be accessible using
System.getProperty() - The main method should be able to send back appropriate message to the shell script to display it on the console.
I read on StackOverflow that this can be done by writing the string to stdout with:
System.out.println("My message");
My question is how should the shell script command be written for the above java class call?
Currently I was playing around with this and it's not working:
output = $JAVA -classpath "$CLASS_PATH" -jar /location_of_jar/myjar.jar packagenameofmyclass.MyClass -Dusr.dir=$CUR_DIR $input1 $input2 RC=$?
echo "$output"
$JAVA CLASS_PATH CUR_DIR is a variable whose value I have set above in the script file.
Please could someone help me out? Am I even going in the right direction.