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.

[502 byte] By [linuxchilda] at [2007-11-26 18:16:04]
# 1

"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.

paulcwa at 2007-7-9 5:49:38 > top of Java-index,Java Essentials,Java Programming...
# 2
> One way I suppose you could do this would be to use> Runtime.exec(). (Or ProcessBuilder if you're using> JDK 1.5.)> thank you ,I will be using ProcessBuilder
linuxchilda at 2007-7-9 5:49:38 > top of Java-index,Java Essentials,Java Programming...
# 3
Not the best solution but it should work.
paulcwa at 2007-7-9 5:49:38 > top of Java-index,Java Essentials,Java Programming...