Reputation: 43
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:
args[0]
System.getProperty()
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.
Upvotes: 1
Views: 9270
Reputation: 37295
Try:
output=`$JAVA -classpath "$CLASS_PATH" -jar /location_of_jar/myjar.jar packagenameofmyclass.MyClass -Dusr.dir=$CUR_DIR $input1 $input2`
The ` marks should make it execute.
Upvotes: 1