Using JBox2D in ruby-processing
Here we demonstrate how to use JBox2D library as a rubygem. This approach could be an exemplar of how to use other processing/java libraries with ruby-processing

Web Links
Box2D for processing on github
Licensing
Daniel Murphy is currently claiming ownership of jbox2d (although surely a derived work):-
Copyright (c) 2014 Daniel Murphy
Dan Shiffman wrote the original PBox2D for processing (on which this implementation is based)
Copyright (c) 2014 Daniel Shiffman
This gem was created by Martin Prout
Copyright (c) 2014 Martin Prout
To compile
To compile the gem follow the instructions for JRubyArt, but also available as a ruby gem:-
jruby -S gem install box2d
Like really easy, but if you have to use rvm or rbenv you will also know what to do (but then you might find this all a bit difficult to understand, and wonder where the tests are, believe me you should throw away those crutches).
To use
You need to require 'pbox2d' in the the usual way (to require a gem) but as in the included examples you must also include ContactListener interface (by jruby magic, including the interface as a module implements the java interface). Now you should create a new instance of Box2D.
@box2d = Box2D.new(self)
box2d.create_world
box2d.gravity(0, -20) # to set a custom gravity
That's about all you need to know, use the box2d instance to access the jbox2d physics world. Ordinarily (with jbox2d) you need to set some other parameters, and call box2d.step in the draw loop, to update the physics world.
To make things dead simple, we have set those parameters to sensible defaults, and call step in the draw loop for you (under the hood using java reflection). The other thing you should know is there is a mismatch between the physics world and the sketch world (processing got it wrong to my view, down is up), further the scaling is different. This is why you need to keep translating from one worlds (coordinates) to the others coordinates, Dan Shiffman explains it in his Nature of Code book, Chapter 5 physics libraries, not that I've read it, I prefer to read code or Sandi Metz.