James Potter acts like a jerk mostly whenever he's around the beautiful Lily Evans, and has no concept of how to reign in his overly extroverted personality to accomodate her wishes and desires.
This is set after Half Blood Prince but before Deathly Hallows. It doesn't follow canon, it's simply my interpretation of what might be happening at Hogwarts whilst Harry isn't around and the impact his non-presence has on Ginny.