Using the gstreamer jar in jruby

Hi all,

I’m trying to use the Gstreamer jar in jruby, but I can’t manage to get
it going.
This is what I’m doing:

[email protected]:~$ jirb
irb(main):001:0> include Java
=> Object
irb(main):002:0> require ‘/home/leon/Desktop/jna-3.0.jar’
=> true
irb(main):003:0> require ‘/home/leon/Desktop/gstreamer-java-0.6.jar’
=> true
irb(main):004:0> Gst
NameError: uninitialized constant Gst
from (irb):5:in const_missing' from (irb):5:inload_history’
irb(main):005:0>

Here’s the homepage for the library:
http://code.google.com/p/gstreamer-java/

What am I doing wrong?

I’m using this version btw:
[email protected]:~$ jruby --version
ruby 1.8.6 (2008-03-19 rev 6255) [amd64-jruby1.1RC3]

Leon B. wrote:

I’m using this version btw:
[email protected]:~$ jruby --version
ruby 1.8.6 (2008-03-19 rev 6255) [amd64-jruby1.1RC3]

Got it. Had to do:
import org.gstreamer.Gst

But now I get:

no init with arguments matching [class java.lang.String, class
java.lang.String] on object JavaUtilities (NameError)

Could somebody help me with that?

OK. Maybe I’m not understanding it right. Is JNA useable in a (j)ruby
script? Or can it only be accessed via Java?

This piece of code too doesn’t work:

include Java
import com.sun.jna.Native;

class TestClass
end
Native.load_library(“c”, TestClass.class)

And if I look at the Java counterparts: they’re doing exactyle the same!
Do I have to enable something to make external java libraries work in
Jruby?

The examples used here:
http://wiki.jruby.org/wiki/Calling_Java_from_JRuby
do work!

I saw in the source code that the Gst.init() method wants a ‘String[]’
argument. What is the jruby equivelant of this? I tried to initialize
the String[] with:

a = Java.lang.String[]

but that didn’t work. It gave back a regular ruby class.

Pfff

When I do the following, I’m getting the same error:
[email protected]:~$ jirb
include Java>> include Java
=> Object

require ‘/home/leon/src/jruby/trunk/build_lib/jna.jar’
=> true

import com.sun.jna.Native
=> Java::ComSunJna::Native

Native.loadLibrary ‘/usr/lib/libgstreamer-0.10.so’
NameError: no loadLibrary with arguments matching [class
java.lang.String] on object Java::ComSunJna::Native

Leon B. wrote:

I saw in the source code that the Gst.init() method wants a ‘String[]’
argument. What is the jruby equivelant of this? I tried to initialize
the String[] with:

a = Java.lang.String[]

but that didn’t work. It gave back a regular ruby class.

Found it!
java.lang.String[0].new

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs