Generate first N primes in Java

import java.util.Scanner;
 
public class PrimeNumber
{
   public static void main(String args[])
   {
      int numberOfPrimes, isPrime = 1, prime = 3;
 
      Scanner in = new Scanner(System.in);
      System.out.println("Number of primes to generate");
      numberOfPrimes = in.nextInt();
 
      if (numberOfPrimes >= 1)
      {
         System.out.println("First "+numberOfPrimes+" prime numbers are :-");
         System.out.println(2);
      }
 
      for ( int cnt = 2 ; cnt <=numberOfPrimes ;  )
      {
         for ( int j = 2 ; j <= Math.sqrt(prime) ; j++ )
         {
            if ( prime%j == 0 )
            {
               isPrime = 0;
               break;
            }
         }
         if ( isPrime != 0 )
         {
            System.out.println(prime);
            cnt++;
         }
         isPrime = 1;
         prime++;
      }         
   }
}


Execution output

Number of primes to generate
6
First 6 prime numbers are :-
2
3
5
7
11
13