How to find out which settings.xml file maven is using

for finding which settings.xml file maven is using, Use the Maven debug option as below

                      root@INA238PMR8-BNG-TECH:/srv/source# mvn -X

The below is the sample output of mvn -X :

root@INA238PMR8-BNG-TECH:/srv/source# mvn -X
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 19:21:28+0530)
Maven home: /srv/canvera/maven/apache-maven-3.0.5
Java version: 1.6.0_37, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/jdk1.6.0_37/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-24-generic", arch: "amd64", family: "unix"
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from /srv/canvera/maven/apache-maven-3.0.5/conf/settings.xml
[DEBUG] Reading user settings from /root/.m2/settings.xml
[DEBUG] Using local repository at /srv/canvera/mvn_repo
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for /srv/canvera/mvn_repo
[INFO] Scanning for projects...

Here, in the above output you would find two settings xml :
(1) global settings xml : /srv/canvera/maven/apache-maven-3.0.5/conf/settings.xml
(2) user settings xml : /root/.m2/settings.xml

user settings xml is the one which maven would be using.

The below attached picture shows output of the above command mvn -X.

settings.xml file maven demo

How to generate random int,long,float,double values

Java provides a class Random which can be used to generate random int,long,float,double values. This Random class is present in java.util package.

It can be instantiated as follows :

           Random  r = new Random();

There are different methods available in Random class for generating random values.

nextInt() — generates random int values without any upper or lower limit
nextLong() — generates random long values without any upper or lower limit
nextBoolean() — generates random boolean values either true or false
nextFloat() — generates random float values between 0.0 and 1.0
nextDouble() — generates random double values between 0.0 and 1.0
nextInt(int upperlimit) — generates random int values withing upper limit

The below demo program illustrates to generate random int,long,float,double values. It generates 10 random values for each type. Only for int type, method is available for generating random value with upper limit.

(Click Here To Read More)