Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the `Java Options` in jenkins ant build tool to set ANT_OPTS

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. enter image description here

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.

like image 680
Michael Avatar asked Jun 19 '11 06:06

Michael


People also ask

Where do you configure Java and Ant in Jenkins?

Go to Manage Jenkins -> Manage Plugins -> Available and search for Ant Plugin . After it's installed, go back to your job configuration and select a new build step Invoke Ant .

What version of Java does Ant use?

You will need Java installed on your system, version 1.8 or later required. The later the version of Java, the more Ant tasks you get.

Can Jenkins execute Ant project?

To take advantage of the Jenkins Ant plugin, create a freestyle project named 'Apache Ant and Jenkins Build Job Example. ' Run the Jenkins Ant build job and the source code will be pulled from GitHub, the tasks will run, and the application will be compiled, tested and packaged as a WAR file.


2 Answers

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

like image 100
gouki Avatar answered Sep 28 '22 00:09

gouki


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.

like image 45
M.J. Avatar answered Sep 28 '22 01:09

M.J.