This one between Paul and James is easy.
Paul is writing about works of the law.
James is writing about works of faith. He gives two examples. I'll only address one:
Rahab was a prostitute, yet she believed in God. How do I know? Works, not works of the law (for she was an adulteress), works of faith. How so? She was willing to lay her life on the line in order to help the spies....
That's a faith that works by love....On the other hand, Paul is right, by the works of the law no one will be justified. No one is good enough.
Keep in mind Rahab was already just in the coming Messiah. Her works of faith proved her faith.