Is it possible to factory reset Sony Xperia J when I forgot the pattern code?
You can do this:
1. Download an app called "PC Companion" (Link)
2. Install and run it.
3. Select the option "Support Zone New!" then click "Start"
4. Wait the program to install a add on
5. Select "Phone / Tablet Software Update" and click "Start"
6. Select "Repair my phone / tablet"
7. Follow the Instruction
8. Chose your phone model
9. Connect your phone to your PC and wait.  

DONE!