We have a project (say, Foo) which has some public static
methods, some of them return String
. Now, I need to access that project's jar
from command-line and call one of those public static String
methods to get that String.
EDIT 1:
I need to pass that returned string as an argument to a shell script. Something like this:
./my_bash_script.sh <value returned from jar> <more arguments>
How do we do it?
Tried to call the jar from command-line, but that didn't help.
java -cp Foo.jar full.package.name.ClassName
Error: Could not find or load main class jar
It was expected, since the class doesn't have a Main function.
Also tried to add a wrapper around the Foo.jar. Like, added this jar (Foo.jar) in my other project as a dependency, and called public static String
method from Foo.jar
. Well, this works, but I have to return a String outside Java application and Main has to be void
.
Can anyone please help me with this?
Please ask for more explanation, if I have left out any detail, before down-voting.