You need to initialize the random Class with a seed, if you don't doit, the seed is base in the time and it is diferent each time.use a fixed long for seedRandom random = new Random( 10 );int number = random.nextInt();