How do I get access token from Foursquare?

I get code from this direct url with my client id and redirect uri;

But I can’t do it with the rest service. I have to embed this service in my java application and then get access token. I can use that different option,if there is another way you know to get access token.Can you help me?