maybe this is what you want.Try and tell me.

Code:
import java.io.*;
public class Number1{
    
public static void main (String [] args) throws IOException{
    
    InputStreamReader reader = new InputStreamReader(System.in);
    BufferedReader in =new BufferedReader(reader);
    String text="";
    int number=-1;
    while(number<=0){
        System.out.print("Enter the number:");
        text=in.readLine();
        try{
           number=Integer.parseInt(text);
           if (number<=0) System.out.println("number must be positive and not 0!!!");
        }catch(NumberFormatException e){
           System.out.println("error enter a number!!!");
        }
        
    }
    //now you have a number to check for factors
    if (number==1) 
           System.out.println("1 is prime number");
    else{
        int n=number;
        int i;
        int factors=0;
        for (i=2;i<n;i++){
            while (number%i==0){
                 factors++;
                 number/=i;
                 System.out.println("factor="+i);
            }
            
        }
        if (factors>0) 
             System.out.println("\nnot a prime number");
        else
             System.out.println("\nit is a prime number!!!");
    }    
}
}