Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > please help, understanding RJB valid syntax

Reply
Thread Tools

please help, understanding RJB valid syntax

 
 
scootiePuff
Guest
Posts: n/a
 
      04-03-2008

i have some basic syntax/format questions for how to begin using RJB
properly, once successfully installed.

i've been having a lot of trouble getting the ruby scripts (within a
rails app) i wrote that make use of rjb to communicate with some 3rd
party java .jar and .java files to work. i posted some of this at the
rjb-users forum at rubyforge, and received some answers there, but i
am still highly confused and would like responses from others who have
been able to successfully use this tool here.

ultimate goals:
load multiple .jar files with rjb, then begin importing 3rd
party .java classes for use in rails' ruby script(s).


1. for the default load line from the online docs i've encountered,
Rjb::load(classpath = '.', jvmargs=[])

i was told that i can use something like this:
Rjb::load"#{RAILS_ROOT}/lib/3rdpartystuff/file1.jar"

now, if i have multiple .jar files that i would like to load, is it
valid to supply multiple arguments to the above load line in the
format below? if not, what is the proper way to do this?
Rjb::load"#{RAILS_ROOT}/lib/3rdpartystuff/file1.jar, #{RAILS_ROOT}/lib/
3rdpartystuff/lib/file2.jar"

or do i load each one separately, each on a separate line?
Rjb::load"#{RAILS_ROOT}/lib/3rdpartystuff/file1.jar"
Rjb::load"#{RAILS_ROOT}/lib/3rdpartystuff/lib/file2.jar"
etc.?

can i alternatively specify,
Rjb::load(classpath = '#{RAILS_ROOT}/lib/3rdpartystuff/', jvmargs=[])
or multiple paths in the first argument,
Rjb::load(classpath = '#{RAILS_ROOT}/lib/3rdpartystuff/, #{RAILS_ROOT}/
lib/3rdpartystuff/lib', jvmargs=[])
?
(alternatively, without the 'jvmargs' argument.)

are wildcards ("*") useable in the arguments? eg,
Rjb::load"#{RAILS_ROOT}/lib/3rdpartystuff/*" (to accommodate ALL
the .jar files that i'd like loaded in the various children
subdirectories ?)


2. from what i understand, the alternative way to load the jvm
(instead of using Rjb::load), is to use the ENV['CLASSPATH'] approach:
ENV['CLASSPATH'] = "#{RAILS_ROOT}/lib/3rdpartystuff/
file1.jar:#{RAILS_ROOT}/lib/3rdpartystuff/lib/file2.jar"
where each of the paths are separated by a colon (":").
am i understanding this correctly, so that ENV['CLASSPATH']
essentially actually alternatively loads the jvm?

3. how can i tell that the .jar files above have indeed been
successfully 'loaded'?

the next step is for me to begin importing the 3rd party .java classes
in order to instantiate objects and start using their methods.

i do something like this,
test_import = Rjb::import('com.3rdpartyco.3rdpartyproduct.servic es.
3rdpartysvcname.SomeSvcClass')

the problem is that i keep encountering the error message,
Exception in thread "main" java.lang.NoClassDefFoundError: com.
3rdpartyco.3rdpartyproduct.services.3rdpartysvcnam e.SomeSvcClass

so i'm not so sure that the .jar files have been successfully loaded,
or how to otherwise direct rjb to find the java classes' files ?


please advise. how would you approach the above problems?




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
please help understanding syntax John Goche Java 5 01-16-2012 10:05 AM
Please Help in understanding a VHDL syntax buddy249 VHDL 1 06-23-2009 11:55 AM
RubyJavaBridge (rjb) Tim Swetonic Ruby 0 07-24-2006 09:24 PM
rjb and Java 1.5 Adam Keys Ruby 0 03-10-2006 12:17 AM
RJB 0.1.6 on 1.8.2 Zach Dennis Ruby 1 11-18-2004 04:13 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57