In context, James clearly occupies the word justify to mean vindication, or proven. He does not argue against justification by faith alone, but rather, a salvation that stands without any good works to accompany it. In other words, one's lifestyle must be consistent with his or her profession of faith. Faith will certainly be accompanied with good works because the heart is regenerated by the Spirit of God. If our Christian testimony is not supported with evidence of good character, then the unbelieving world will have no reason to deem our witness for Christ trustworthy or reliable.
What James is saying is that we demonstrate the reality of our faith by good works. Are we going to merely talk the spiritual talk or actually going to walk the spiritual walk (James 2:14-17)? Are we only going to be hearers of the Word or doers of the Word (James 1:21-22; 26-27)? The question that James addresses is, "Can such faith save a man?" It is not enough to mentally accept the fact that God exists (James 2:19-20). Therefore, James distinguishes between two different kinds of faith. The demons acknowledge that whatever God says is the truth, but are not in fellowship with Him because they lack trust.
Works are the product or result of a genuinely saving faith. A converted heart by definition will result in a changed life of holiness. James 2:18 especially echoes this theme ("a man may say...show me...I will show you..."). The inspired writer James provides two biblical examples to illustrate his point on the relationship between faith and works (James 2:21-25). The faith of Abraham and Rehab was tested and shown to be true. Faith was "perfected" in that it reached its design or end. An analogy is employed to make the point that faith and works cannot to be separated from each other (James 2:26). The Christian walk is one that glorifies God.