You can use Document.getPageCount method to get the page count of a doc / docx file in Aspose.Words for Java. Following is the sample code:
//Open the Word Document
Document doc = new Document("C:\\Data\\Image2.doc");
//Get page count
int pageCount = doc.getPageCount();
//Print Page Count
System.out.println(pageCount);
Hope this helps.