You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Daniele Development-ML <da...@googlemail.com> on 2009/08/22 21:05:13 UTC

Java Memory Error when invoking programmatically Ant API

Hi everybody,
I'm porting the following piece of Java code:

       Project project = new Project();
        Target target = new Target();
        SignJar sj = new SignJar();
        target.addTask(sj);

        project.addTarget("sign_jar", target);

        sj.setKeystore(sigFile);
        sj.setAlias("signalias");

        sj.setKeypass("keypassword");
        sj.setStorepass("keyStorePass");

        sj.setProject(project);
        sj.setVerbose(true);
        sj.setJar(file);

        sj.setMaxmemory("100m");

        project.executeTarget("sign_jar");

>From Windows to Linux, and I'm getting the following exception:

java.io.IOException error code=12 : cannot allocate memory.

The stack trace indicated that the statement raising the exception is
project.executeTarget. From a search in the web I have found out that this
problem can be solved by setting the fork attribute to true, when using the
javac task in the conventional way (i.e. using the build.xml file, and not
invoking the Ant API programmatically).

I'm browsing the API but I can't find a way to set this attribute -
providing it would be valid for the SignJar task.

Any suggestion/help are very much appreciated.

Thanks,

Dan