|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "Getting Started Buster" |
| 4 | +date: 2019-11-11 07:34:13 |
| 5 | +categories: PiCrate update |
| 6 | +permalink: /getting_buster/ |
| 7 | +--- |
| 8 | +Currently Raspbian Buster does not come with a pre-installed java. So the first step is to install a `jdk` we currently recommend installing openjdk8 (_there a complications you don't need using jdk11_) to benefit from `client` optimisations. |
| 9 | + |
| 10 | +```bash |
| 11 | +sudo apt-get update # sync your local database with current release |
| 12 | +sudo update # update to latest release |
| 13 | +sudo apt install openjdk-8-jdk # installs latest jdk8 |
| 14 | +java -version # check installed version |
| 15 | +``` |
| 16 | +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:- |
| 17 | +```bash |
| 18 | +sudo update-alternatives --config java |
| 19 | +sudo update-alternatives --config javac |
| 20 | +sudo update-alternatives --config jar |
| 21 | +``` |
| 22 | +See [java][java] install for more explanations. |
| 23 | + |
| 24 | +__Then install JRuby see__ [jruby][jruby]. |
| 25 | + |
| 26 | +We strongly recommend that you create a local storage for gems on your system, as follows:- |
| 27 | + |
| 28 | +```bash |
| 29 | +mkdir -p ~/.gem/jruby/2.5.0 |
| 30 | +``` |
| 31 | +Now set your `GEM_HOME`, `GEM_PATH` and amend your `PATH` as follows:- |
| 32 | + |
| 33 | +```bash |
| 34 | +echo "export GEM_HOME=\"\${HOME}/.gem/ruby/${MRI_RUBY}\"" >> ~/.profile |
| 35 | +echo "export GEM_PATH=\"\${HOME}/.gem/ruby/${MRI_RUBY}\"" >> ~/.profile |
| 36 | +echo "export PATH=\"\${PATH}:\${GEM_PATH}/bin\"" >> ~/.profile |
| 37 | +source ~/.profile # to update environment without re-logging in |
| 38 | +``` |
| 39 | +Now should be ready to install `picrate` and other gems. |
| 40 | +Install a local version of rake:- |
| 41 | +```bash |
| 42 | +jgem install rake |
| 43 | +``` |
| 44 | +To install picrate and its dependencies:- |
| 45 | + |
| 46 | +```bash |
| 47 | +jgem install picrate |
| 48 | +``` |
| 49 | +__For a first install:-__ |
| 50 | + |
| 51 | +```bash |
| 52 | +picrate --install # no args, install samples and geany config |
| 53 | +# or |
| 54 | +picrate -i Samples # to omit geany config |
| 55 | +``` |
| 56 | + |
| 57 | +This installs example sketches in `~/sample_sketches` and ties them into a `geany` project `picrate.geany`. It should also be possible to run sketches from the `geany` ide. |
| 58 | + |
| 59 | +To create a template sketch from the command line:- |
| 60 | + |
| 61 | +```bash |
| 62 | +picrate -c my_sketch 600 400 |
| 63 | +``` |
| 64 | +creates file my_sketch.rb |
| 65 | + |
| 66 | +```ruby |
| 67 | +#!/usr/bin/env jruby |
| 68 | +# frozen_string_literal: false |
| 69 | +require 'picrate' |
| 70 | + |
| 71 | +class MySketch < Processing::App |
| 72 | + def settings |
| 73 | + size 200, 200 |
| 74 | + end |
| 75 | + |
| 76 | + def setup |
| 77 | + sketch_title 'My Sketch' |
| 78 | + end |
| 79 | + |
| 80 | + def draw |
| 81 | + |
| 82 | + end |
| 83 | +end |
| 84 | +MySketch.new |
| 85 | + |
| 86 | +``` |
| 87 | + |
| 88 | +Edit in `vim` (at command line) or `geany` (gui), you may need to install `vim` |
| 89 | +```bash |
| 90 | +vim my_sketch.rb |
| 91 | +:!jruby % # from vim runs the sketch |
| 92 | +``` |
| 93 | + |
| 94 | +To run sketches from command line:- |
| 95 | + |
| 96 | +```bash |
| 97 | +jruby my_sketch.rb |
| 98 | +``` |
| 99 | + |
| 100 | +Or even `chmod +x my_sketch.rb` to make an executable script. |
| 101 | + |
| 102 | +See [editors][geany] geany, for how to run sketches from a gui. |
| 103 | + |
| 104 | +### JWishy Sketch Running on RaspberryPI |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +[java]:http://ruby-processing.github.io/java/raspberry/ |
| 110 | +[jruby]:{{ site.github.url }}/install_jruby/ |
| 111 | +[geany]:{{ site.github.url }}/editors/geany |
0 commit comments