Ant calling taskkill on out of memory
I am having trouble adding the
-XX:OnOutOfMemoryError="taskkill /F /PID %%p"
argument to a java command in ant.
When I add
<jvmarg value="-XX:OnOutOfMemoryError="taskkill /F /PID %%p""/>
or
<jvmarg value="-XX:OnOutOfMemoryError=\\"taskkill /F /PID %%p\\""/>
Ant fails to parse the XML file.
If I do this
<jvmarg va开发者_如何学编程lue="-XX:OnOutOfMemoryError="taskkill /F /PID %%p""/>
Then i get
[java] Caused by: java.lang.ClassNotFoundException: .F
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Anyone know the correct way to do this so that the JVM gets the correct args?
Thanks Neil
XML allows single quotes for argument values:
<jvmarg value='-XX:OnOutOfMemoryError=\"taskkill /F /PID %%p\"'/>
This will correct the xml syntax problem of the build file.
Edited the line of code above. From a post in a different forum I learned, that the quotes have to be escaped, otherwise it leads to the "ClassNotFoundException" that you encountered too.
After a quick test of creating an out of memory, the quotes actually aren't needed :)
<jvmarg value="-XX:OnOutOfMemoryError=taskkill /F /PID %p"/>
I've been stuck on this for hours and never actually tested it without the quotes.
It turns out that the special is for bat files which do need the quotes, like this
-XX:OnOutOfMemoryError="taskkill /F /PID %%p"
精彩评论