Hi Damian,
thanks for your quick reply.

Damian Steer wrote:
> On 8 Dec 2011, at 18:45, Paolo Castagna wrote:
> 
>> How can I setup the classpath for the jruby command?
> 
> From within jruby you can use:
> 
> $CLASSPATH << 'path/to/some.jar'

I like this approach, I tried it and it works fine.

This is what I added to the hello_jena.rb JRuby script:
Dir["target/dependency/\*.jar"].each { |jar| require jar }
Dir["target/jena-examples-\*.jar"].each { |jar| require jar }

This is to package and copy all the dependencies to a local directory:
mvn clean package dependency:copy-dependencies

Then I can run the script with:
jruby src/main/jruby/hello_jena.rb

> Since you want to use maven try the (very temperamental) gem / maven bridge:
> 
> $ gem install mvn:com.hp.hpl.jena:jena -v 2.6.4
> Successfully installed mvn:com.ibm.icu:icu4j-3.8.0-java
> Successfully installed mvn:com.hp.hpl.jena:iri-0.8.0-java
> Successfully installed mvn:xml-apis:xml-apis-1.4.01-java
> Successfully installed mvn:xerces:xercesImpl-2.10.0-java
> Successfully installed mvn:com.hp.hpl.jena:jena-2.6.4-java
> 5 gems installed

I tried this, but it did not work for me:
ERROR:  could not find gem mvn:com.hp.hpl.jena:jena locally or in a repository
(but I probably have an obsolete Ruby/gem installation. Don't worry.)

> $ irb
> jruby-1.6.5 :001 > require 'java'
>  => true 
> jruby-1.6.5 :002 > require 'rubygems'
>  => true 
> jruby-1.6.5 :003 > require 'mvn:com.hp.hpl.jena:jena'
>  => true 
> jruby-1.6.5 :004 > java_import 'com.hp.hpl.jena.rdf.model.ModelFactory'
>  => Java::ComHpHplJenaRdfModel::ModelFactory 
> jruby-1.6.5 :005 > ModelFactory.create_default_model
>  => #<Java::ComHpHplJenaRdfModelImpl::ModelCom:0x28bd36fa> 
> 
> (note that I'm using jruby via rvm here. You might want to use jruby -S gem 
> install .... and jirb)

This rvm (http://beginrescueend.com/)?
I am not sure I'll go down this route... for now. :-)

Paolo

PS:
I'd like to have similar examples for Scala, Jython and Groovy.

> 
> Damian
> 
> 

Reply via email to