Write a Java program that prompts the user for an integer and then prints out all the prime numbers up to that Integer?

public class NegativeArraySizeExceptionExample {
    public static void main(String[] args) {
        try {
            int[] array = new int[-5];
        } catch (NegativeArraySizeException nase) {
            nase.printStackTrace();
            //handle the exception
        }
        System.out.println("Continuing execution...");
    }
}