Forum: JRuby PerlinNoiseGenerator - how?

Posted by Na Na (apolloe)
on 2013-01-17 05:54
Hi,

I'm currently trying to get my program running well on jruby rather than
MRI, to see if it can solve some issues I'm having with MRI (primarily
to do with garbage collection, but having real threads may turn out to
be very useful too).  Part of the program involves perlin noise, and I
have been using a ruby c gem that runs very fast.  The perlin_noise gem
based on pure ruby is very slow.  Someone recommended I try this:
http://code.j3d.org/javadoc/org/j3d/texture/proced...

However, being unfamiliar with both java and jruby, I don't know how to
get this working.  I've tried:

require 'java'

module Java3D
  include_package "org.j3d.texture.procedural"
end


class Generator
  include Java3D
  def initialize
    @test = Java3D::PerlinNoiseGenerator.noise2(4,4)
    @test = Java3D::PerlinNoiseGenerator(4,4,4)
  end
end

Neither of these @test assignments work (I did not try both at once, of
course).  Is there something I might be missing?

I'm running this on mac osx, and installed jruby via rvm (jruby-1.7.1).

Thanks!
Posted by Mark Mandel (Guest)
on 2013-01-17 06:22
(Received via mailing list)
This is the section of the wiki you need to read:
https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby

The bit it *looks* like you are missing is requiring the jar file.

require 'path/to/mycode.jar'

I personally prefer java_import over include_package, but that is 
probably
just my preference.

Although some errors messages / stack traces of what is going wrong 
would
be useful, as I can only assume this is your issue.

Mark


On Thu, Jan 17, 2013 at 3:54 PM, Na Na <lists@ruby-forum.com> wrote:

>
> class Generator
> I'm running this on mac osx, and installed jruby via rvm (jruby-1.7.1).
>
>
>


--
E: mark.mandel@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

2 Devs from Down Under Podcast
http://www.2ddu.com/
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.