Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify a global system property for java applications?

I'm trying to integrate Cobertura into our test environment to be able to capture code coverage information. The tests are run from ant scripts using ANT junit tasks, and there are more than 50 ant script files (build.xml) with one or more junit task definitions.

As per the Cobertura doc, the junit tests have to be given the path of the cobertura coverage data file through the sysproperty nested element of the junit task. What it means to me is that I will need to update all those 50+ files to specify a sysproperty element for the junit tasks, which I plan to do as a last resort.

I'm running my tests in Linux (CentOS) and I would like to know if there is a way to specify a global system property (-Dxxx=yyy) so that the system property is made available to all java applications running in the system.

-EDIT-
The junit tests are run in a forked JVM. <junit fork="yes" ...

like image 944
srkavin Avatar asked Nov 16 '11 20:11

srkavin


1 Answers

You can try to set ANT_OPTS environment variable.


ANT_OPTS - command-line arguments that should be passed to the JVM. For example, you can define system properties or set the maximum Java heap size here.


-EDIT-

You have to set _JAVA_OPTIONS environment variable. Here and here there is some information about it.

like image 99
szhem Avatar answered Oct 13 '22 05:10

szhem