Skip to content
Martin Prout edited this page Aug 10, 2015 · 18 revisions

Why do I need to include settings method in my sketch

Since processing-3.0 that is where processing expects you to set size/mode/smooth/full_screen, if you are using processing ide this gets hidden from you.

How can the processing jars be included in the jruby_art gem

We can do this because by only including the "core" jars, and moving out the samples. Vanilla processing-3.0 is becoming more modular and video and sound libraries are now loaded separately, so we are moving in the same direction.

The jruby-complete jar is not included in the jruby_art gem

The tool for downloading and installing jruby-complete works well, but it is not even needed for many sketches, or at all if using the netbeans ide (with ruby-plugin), the size of jruby-complete would make the gem too big.

Why do I keep getting these warning messages when I run jruby_art sketches?

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.

How do I ensure that ruby-complete is used to run a sketch

Use the k9 --nojruby run command (or set config JRUBY: 'false')

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.

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

If you are using jdk8 -XX:+TieredCompilation is definetly 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).