How to use the `Java Options` in jenkins ant build

2019-02-21 18:44发布

问题:

I have a problem with a junit ant build, i'm getting a java.lang.OutOfMemoryError: PermGen space error.

I'm trying to set ANT_OPTS to be ANT_OPTS='-Xmx512m -XX:MaxPermSize=256m' in the build Java Options to increase the heap size ant build tool.

But i get an error each time i run:

Exception in thread "main" java.lang.NoClassDefFoundError: ANT_OPTS=-Xmx512m -XX:MaxPermSize=256m
Caused by: java.lang.ClassNotFoundException: ANT_OPTS=-Xmx512m -XX:MaxPermSize=256m
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: ANT_OPTS=-Xmx512m -XX:MaxPermSize=256m.  Program will exit.

A syntax error ?

Thanks.

回答1:

Set the JAVA OPTIONS as -Xmx512m -XX:MaxPermSize=256m only without the ANT_OPTS=



回答2:

Also, u can add memory option in the build file also, like memoryInitialSize="256m" memoryMaximumSize="512m". this will help. as i am using the same, and it caused no problem till now.