So whoever knows the right thing to do and fails to do it, for him it is sin. (ESV)
I have known people who thought that they were going to heaven based on the fact that they did not do anything that warranted their being punished. It is one of many lies that man believes. We think that because we are better than the really evil people (murderers, rapists, people who disagree with us) we somehow will be declared right before God.
Enter James 4:17. James takes the standard of God's holiness and makes it even more impossible for us to attain. He is saying here that it isn't avoiding sins that is all that is required. He tells us that if you knew the right thing to do and you did not do it, you have sinned. Is there anyone on the planet who can honestly say that they have always done every right thing they knew they should have done?
God's standard of holiness requires that we avoid sin, and also that we do the righteous things he has required. The more we look into this perfect standard we find that we simply do not match up. We could find all kinds of righteous things to do for God but then realize we forgot to do even more. Avoiding one thing that we know we ought to do is for us, sin.
What is to be done about this predicament that we find ourselves in? We go to the cross. We recognize that Jesus Christ is the fulfillment of all of God's Law. I am not holy because I behave in a holy manner. I am declared holy because of my faith in the sacrifice of Jesus Christ, the perfect fulfillment of the law, on my behalf. The perfect holiness required by God is only done by Jesus Christ.
Are you still looking to your own efforts to be made right with God? You could never do enough righteous things. Even if you could stop doing wrong things, you would not do enough right things. Confess your sin. Ask Jesus to forgive you. Place your faith in his death and resurrection.