I have a jar created by maven with all dependencies in it. I have another java code that wants to use the jar as a library. My java code and the classes in the jar belong to two different packages.
The following shows how I am running the main class in the jar:
java -Dlog4j.configurationFile=src/test/resources/log4j2.xml
-cp pathtojars com.mainclass "parameters to mainclass" "inputfile"
How can i invoke the main class in the jar (equivalent of the above command) and get its STDOUT as a variable after execution is complete in my java code?