ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject AW: Calling ivy from a java class/method
Date Tue, 03 Jul 2007 07:54:18 GMT
You could refactor the content of main() out:

public static void main(String args) {
    Main main = new Main();
public void process(String args) {
    // Use CommandLineParser for configuring Main
public void run() {
    // Ivy's work


>-----Ursprüngliche Nachricht-----
>Von: Xavier Hanin [] 
>Gesendet: Dienstag, 3. Juli 2007 09:39
>Betreff: Re: Calling ivy from a java class/method
>On 7/3/07, Michael Habbert <> 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.
>Mit freundlichen Grüßen
>> Michael Habbert
>Xavier Hanin - Independent Java Consultant
>Creator of Ivy, xooki and
>More about me:

View raw message