please help, understanding RJB valid syntax

S

scootiePuff

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.services.
3rdpartysvcname.SomeSvcClass')

the problem is that i keep encountering the error message,
Exception in thread "main" java.lang.NoClassDefFoundError: com.
3rdpartyco.3rdpartyproduct.services.3rdpartysvcname.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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top