The prime number sieve mentioned aboveis mentioned in another answer, but it's a little harder to use if you want to find a number of primes, rather than all the primes up to a number
You might also want to consider using a Console rather than a Scanner as you can prompt for input rather than have to println then read.
P.S. pre Java 8 primes would look like this:
Collection<Integer> primes(int numPrimes) {
final List<Integer> primes = new ArrayList<>(numPrimes);
int num = 2;
while (primes.size() < numPrimes) {
if (isPrime(num, primes))
primes.add(num);
num++;
}
return primes;
}
boolean isPrime(final int num, final List<Integer> primes) {
for (int prime : primes)
if (num % prime == 0)
return false;
return true;
}