Table of Contents

Java and JVM on Facebook Accelerators

Introduction

This page is a guide to creating and deploying applications on your Facebook Accelerator developed in the Java programming language, and developed in other languages that run on top of the Java Virtual Machine (JVM).

Java Overview

If you're new to Java, the JVM, or want a general introduction to developing and deploying Java applications, start off by reading the Java Overview in the All Accelerators Knowledge Base.

Version

Java is installed version “1.6.0_01”.

You will need to install Geronimo or another J2EE application to serve your application.

Libraries

The Java client libraries that are provided in the standard java include directory are the official facebook Java libraries and include the standard core components:

  1. src directory with FacebookRestClient.java, FacebookJsonRestClient.java, FacebookXmlRestClient.java, FacebookException.java and FacebookMethod.java
  2. ExampleClient application
  3. Classes to verify fb_sig request
  4. bin directory with .jar files needed for compilation and a facebook.jar

The Java documentation is at http://wiki.developers.facebook.com/index.php/Java

Connecting to mysql via JDBC: The mysql JDBC driver connects via TCP/IP. The default mysql settings disallow TCP/IP access (even from localhost). To enable that, comment out the line “skip-networking” in the /opt/local/etc/my.cnf file: SSH in to your server using the admin account and enter 'sudo nano /opt/local/etc/my.cnf', and enter your password. Use Ctrl-O to write to file and Ctrl-X to save and exit.

Warning on Java memory usage in Accelerators

Java automatically sets a heap size when it starts. The default calculation can give undesirable results in Joyent Accelerators (e.g. consuming half the memory in a container for a simple application).

See this thread for further discussion.

To avoid problems, specify heap size parameters when you launch java:

# java -Xms16m -Xmx64m MyJavaApp