running jar file as independent programme ?
hello
Im writing a java programme that will call a jar file passing some argument
here is an example :
main programe : has to calculate the age of person
the main prgramme will call the jar file calculate.jar by providing the date of today
call(calculate.jar -d "13/2/2007")
so my question is how to do this ?
or what is the technical name for this process ? so i can search in google ?
or any one has an example ?
thank you in advance.
"Invoke"? "Delegate"? They're applicable terms. There are probably other terms that have slipped my mind at the moment.
One way I suppose you could do this would be to use Runtime.exec(). (Or ProcessBuilder if you're using JDK 1.5.)
But I think a preferable way would be to look at the class with the main method in the jar file, and find out what it calls. Then treat the jar as a library and invoke the method in question. IMO, if the contents of the jar were well-written, the method with the main() just bootstraps the code and the contents of the jar can otherwise be seen as a (we hope) well-documented library.
Or if you have to you can just invoke the main() method itself, which is a bit of a kluge but would work.