Glad you two got the job!
@Lucylulu66~
Try talking to J, just bring it up casually as Rattielover_55 suggested. You could also mention that you haven't gotten to be partners with J in a while and you can plan to work together ahead of time. Last semester, my class did a lot of two-person group projects and myself and my three friends took turns being partners with each other. If you talk to J, see if you guys can agree to take turns or something similar that could help the problem.
If your teachers doesn't give you a seating plan, the three of you could find some desks that are beside each other then you could both sit by J.
Try and hang out with J when you can, including outside of school, even if P is with her. And if J leaves 'cause she's mad at P again, you could probably try going with her unless she specifically says not to. Sounds like J doesn't much like the way P behaves, it might not be long before she decides she doesn't want to be P's friend.
Hopefully that helps, and, if anything, it'll blow over (or at least become more tolerable

)