Here is a simple java application for accessing facebook. This is done by using restfb, which is a  simple and flexible Facebook Graph API and Old REST API client written in Java.

For this we need an access token which we can generate using graph API explorer in facebook developers website.

Download the restfb jar.

Get an access token with necessary permissions.

package com.amal.fb;

import com.restfb.DefaultFacebookClient;
import com.restfb.FacebookClient;
import com.restfb.Parameter;
import com.restfb.types.FacebookType;
import com.restfb.types.User;

public class FacebookAppnew {
public static void main(String[] args) {
 System.setProperty("https.proxyHost", "PROXY");
 System.setProperty("https.proxyPort", "PORT");
 FacebookClient fbClient = new DefaultFacebookClient("MY_ACCESS_TOKEN");
 User user = fbClient.fetchObject("me", User.class);
 // Getting the Details from FB
 System.out.println("UserName :"+user.getName());
 System.out.println("Birthday :"+user.getBirthday());
 System.out.println("Bio :"+user.getBio());
 System.out.println("Email :"+user.getEmail());

 //Making a post in Facebook
 FacebookType publishMessageResponse =
 fbClient.publish("me/feed", FacebookType.class,
 Parameter.with("message", "Good Evening"));


Similarly we can post photos, videos etc.