On 7/3/07, Michael Habbert <[EMAIL PROTECTED]> wrote:
Hi ivy users, A few days ago I get in contact with ivy (using bevor only ant and maven). Quite fascinated about it a question did came up to my mind. What is the best way to call ivy from a java program? I do know calling: Runtime.getRuntime().exec(comand) will be a way, but don't looks like the best way to me. Thanks in advance for any help or hints.
It depends on what you want to do and how you want your program to evolve. Using Runtime.getRuntime().exec(comand) has the drawback to require to set a classpath independently for Ivy. OTOH, Ivy then runs in another JVM and can't make your calling JVM crash (I don't say that Ivy crashes, but you may have issues with memory consumption if your calling VM is too limited). Another approach is to embed Ivy and call the Main.main(args) method. It's roughly equivalent to Runtime.getRuntime().exec(comand) except that it runs in the same vm. Then you can also call Ivy API (the Ivy class is the main entry point), which is much more flexible than the other options, but this is not a stable API, and you will certainly have to adapt your code when you upgrade your Ivy version. HTH, Xavier Mit freundlichen Grüßen
------------------------------------------------------------------------ Michael Habbert
-- Xavier Hanin - Independent Java Consultant Creator of Ivy, xooki and xoocode.org More about me: http://xhab.blogspot.com/
