We don't have a lot of code examples yet, so you need to look at code examples for C# and essentially do the same in Java.
Here is the home page of the API Reference http://www.aspose.com/Products/Aspose.Words/Api/index.html
To quickly insert something into a header/footer you can use DocumentBuilder.MoveToHeaderFooter and then other DocumentBuilder methods as shown in this example http://www.aspose.com/Products/Aspose.Words/Api/Aspose.Words.DocumentBuilder.MoveToHeaderFooter.html
To insert a field such as "page number x of y" you can use DocumentBuilder.InsertField http://www.aspose.com/Products/Aspose.Words/Api/Aspose.Words.DocumentBuilder.InsertField.html . You can insert a field in MS Word first, see what the field code looks like and then insert same using DocumentBuilder.InsertField. Please note however, that the result of the field (the actual page number or count of pages) will not be calculated by Aspose.Words. Aspose.Words cannot evaluate expressions inside MS Word document fields. You will need to open the document in MS Word, select all and press F9 for the fields to update and show actual page numbers.
We will translate all code examples into Java soon.