Skip to content
Martin Prout edited this page Dec 22, 2013 · 48 revisions

Why are the processing jars no longer included in the ruby-processing gem

Blame the rubygems guys (well don't blame them really in tis entirely understandable), they are not for profit organisation, so they can't afford to deliver large gems for free.

Why are the jruby-complete jars no longer included in the ruby-processing gem

Same as above, although future versions of jruby-complete (version 9000) might be getting smaller.

Why do I keep getting these warning messages when I run ruby-processing?

array_2d.rb:20 warning: ambiguous Java methods found, using background(int)

array_2d.rb:25 warning: ambiguous Java methods found, using stroke(float)

This is because you are using an overloaded java method, ie one that takes more than one type of argument. Background for example can also take an PImage as its argument, and stroke an int. Generally you should not worry about such messages, as jruby makes a sensible choice for you ( it is just being noisy about it ).

Can I avoid getting messages about overloaded methods when calling java?

Yes you can provide signature-specific aliases for overloaded methods, for frequently called methods this might be worth doing, as it reduces the 'overhead' of the look up calls. But for the sake of simplicity, we've not bothered, but there is nothing to stop you though.

# signature-specific aliases for overloaded methods
java_alias :background_int, :background, [Java::int]
java_alias :fill_int, :fill, [Java::int]
# using alias in place of regular method
background_int 0
fill_int 0

Can I export my sketches to javascript, coffeescript?

Absolutely not, this is a feature of vanilla processing (which is antlr parsed code). Here processing code is treated as if it were java, making use of jruby to integrate it with ruby. Nothing to stop you from inventing some cool parser, interpreter, whatever.

Why can't I install ruby-processing-2.X.X from rubygems?

They are a non-profit organisation, and can't afford to continue to serve up large gems for free, so they made a policy decision to limit the size of the gems they host (the original ruby-processing easily exceeds that limit, and the current version is somewhat bigger). The easiest way to get ruby-processing now, is to download the archived latest release and build it on your machine, it is very easy though. If we could rely on a stable classpath, we may able to return to rubygems distribution sans jruby-complete, and using a pre-installed vanilla processing to to provide the required jars.

How does the --nojruby flag work?

Normally running ruby-processing is a two stage process which can kick off from either ruby or jruby, the second stage needs to use jruby, this can be provided by the system installed jruby (using jruby launcher) or by by the included jruby-complete (which is called from java). The --nojruby flag starts ruby-processing from java using jruby-complete.jar.

Why is jruby-complete still included in ruby-processing?

  • The jruby-complete is required to support application export (then only java run-time is needed to run the application). But it may be worth investigating this alternative approach to providing a standalone app.
  • Certain sketches, particularly the GLSL shader sketches need to use jruby-complete ( use --nojruby flag ) to run.

Why is there a difference between using jruby-complete and the system installed jruby

  • According to headius (aka Charles Nutter), there are certain things that happen in the jruby-launcher that can affect permission etc. So for example when using the "fisica" library some 'protected' variables are visible using an installed jruby, but not when using jruby-complete. Unfortunately this a rare instance when system jruby actually works better than jruby-complete. For some other sketches, notably GLSL shader sketches you might need to use the --nojruby flag to get them to run (beyond our control).
  • However if you want use rubygems in your sketches, you absolutely need to use the system installed jruby, and make sure those gems are also installed using jruby ( this is the main reason for changing to use system jruby by default ).

How do increase the memory limit?

Create a 'data' folder if you haven't got one already in that folder create a file "java_args.txt" add the usual jvm command line options to the file eg -Xms756m -Xmx756m (if using jruby this gets converted to -J-Xms756m -J-Xmx756m under the hood, note since jdk7 the limits may already be higher, and limits should not set lower than the default).

What other options can I pass to the jvm

Apparently -XX:+TieredCompilation might be worth trying. Tiered compilation, introduced in Java SE 7, brings client startup speeds to the server VM so this might be particularly interesting to users of 64 bit java (that defaults to server mode).

Can I still write sketches wrapped as a class?

Absolutely this is still a valid sketch

class My_Sketch < Processing::App
  def setup
    size 100, 100
  end
end

However it is unnecessary to provide such a wrapper (it gets added for you). It is even possible to write, a completely minimalist sketch such as the following, but this is just a hack for a bit of fun (translated from a vanilla processing sketch by R Brauer). This sketch relies on the fact that if you do not supply setup or size, they get added for you by default.

S, V, D = 400, [], 0.02

def draw
  S.times { |a| V << [a, rand * S]; g = noise(V[a][0] * D, V[a][1] * D) * 6; point(V[a][0] += sin(g), V[a][1] += cos(g))}
end
Clone this wiki locally