RaspberryPI OS usually comes with a pre-installed jdk11. Before installing JRuby it might be worth setting the JAVA_HOME environmental variable (to supress reflection warnings).

Otherwise follow these instructions in order as needed:-

sudo apt-get update # sync your local database with current release
sudo update # update to latest release
sudo apt install openjdk-11-jdk # installs latest jdk11
java -version # check installed version

If you have already installed a version java the java version may not match you can control the active java version on Debian using update-alternatives as follows:-

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config jar

See java install for more explanations.

Then install JRuby see jruby.

We strongly recommend that you create a local storage for gems on your system, as follows:-

mkdir -p ~/.gem/jruby/2.5.0

Now set your GEM_HOME, GEM_PATH and amend your PATH as follows:-

echo "export GEM_HOME=\"\${HOME}/.gem/ruby/${MRI_RUBY}\"" >> ~/.profile
echo "export GEM_PATH=\"\${HOME}/.gem/ruby/${MRI_RUBY}\"" >> ~/.profile
echo "export PATH=\"\${PATH}:\${GEM_PATH}/bin\"" >> ~/.profile
source ~/.profile # to update environment without re-logging in

Now should be ready to install picrate and other gems. Install a local version of rake:-

jgem install rake

To install latest picrate and its dependencies:-

jgem install picrate

For a first install:-

picrate --install # no args, install samples and geany config
# or
picrate -i Samples # to omit geany config

This installs example sketches in ~/projects/examples and ties them into a geany project examples.geany. It should also be possible to run sketches from the geany ide.

To create a template sketch from the command line:-

picrate -c my_sketch 600 400

creates file my_sketch.rb

#!/usr/bin/env jruby
# frozen_string_literal: false
require 'picrate'

class MySketch < Processing::App
  def settings
    size 200, 200
  end

  def setup
    sketch_title 'My Sketch'
  end

  def draw

  end
end
MySketch.new

Edit in vim (at command line) or geany (gui), you may need to install vim

vim my_sketch.rb
:!jruby % # from vim runs the sketch

To run sketches from command line:-

jruby my_sketch.rb

Or even chmod +x my_sketch.rb to make an executable script.

See editors geany, for how to run sketches from a gui.

JWishy Sketch Running on RaspberryPI

jwishy_buster