« Return to Thread: Dynamically adding to classpath

Re: Dynamically adding to classpath

by Chris Evans-8 :: Rate this Message:

Reply to Author | View in Thread

For some reason, neither of these worked for me.  My app is making a
SOAP connection to the Websphere server.  When I add the websphere
jars to the classpath in the jruby executable, it works.  If I append
the jars in the script, either through $CLASSPATH << or 'require
blah.jar', the script fails.  It doesn't look like a ClassNotFound
error, either, it seems to be loading the classes but the SOAP
connection fails.

Chris

On Wed, Mar 5, 2008 at 3:05 PM, Lenny Marks <lenny@...> wrote:

> You can also append to the $CLASSPATH global at runtime(unless that's
>  frowned upon these days). Here's an old post about what we were doing
>  (still more or less the same).
>
>  http://archive.jruby.codehaus.org/user/B5A15A45-71F7-4432-8F10-
>  C892023A157F%40aps.org
>
>  Also..
>
>  http://wiki.jruby.org/wiki/FAQs#How_come_Java_can.
>  27t_find_resources_in_class_folders_that_I.27ve_appended_to_the_.
>  24CLASSPATH_global_variable_at_runtime.3F
>
>  -lenny
>
>
>
>  On Mar 5, 2008, at 11:39 AM, Chris Evans wrote:
>
>  > well, its still pretty cool :)
>  >
>  > On Wed, Mar 5, 2008 at 11:33 AM, Nick Sieger <nicksieger@...>
>  > wrote:
>  >> No, you still need to use "import" or "include_class" unfortunately.
>  >>  This is just shorthand for making them available on the classpath.
>  >>
>  >>  /Nick
>  >>
>  >>
>  >> On Mar 5, 2008, at 9:40 AM, Chris Evans wrote:
>  >>
>  >>> If I require the jars this way, do I also need to include_class the
>  >>> classes I need, or will they be available because of the require?
>  >>> Because that would be really cool :)
>  >>>
>  >>> Chris
>  >>>
>  >>> On Tue, Mar 4, 2008 at 11:31 PM, Nick Sieger <nicksieger@...>
>  >>> wrote:
>  >>>>
>  >>>> On Mar 4, 2008, at 8:37 PM, Chris Evans wrote:
>  >>>>
>  >>>>> I'm working on a module for managing Websphere, using Jruby and
>  >>>>> Websphere MBeans. It works great, but I've modified jruby.sh to
>  >>>>> add
>  >>>>> the (numerous) needed $WAS_HOME/lib jar files to the classpath.
>  >>>>>
>  >>>>> I'd prefer to give my module the name of the WAS_HOME/lib
>  >>>>> directory,
>  >>>>> and have my module add the needed jars to the load path or
>  >>>>> classpath
>  >>>>> programmatically, leaving jruby.sh untouched ( and my command line
>  >>>>> clean and simple)
>  >>>>>
>  >>>>> Possible?
>  >>>>
>  >>>> Sure -- try
>  >>>>
>  >>>> Dir[ENV['WAS_HOME'] + '/lib/*.jar'].each {|jar| require jar}
>  >>>>
>  >>>> -- assuming WAS_HOME is present in the environment.
>  >>>>
>  >>>> Cheers,
>  >>>> /Nick
>  >>>>
>  >>>> -------------------------------------------------------------------
>  >>>> --
>  >>>> To unsubscribe from this list, please visit:
>  >>>>
>  >>>>    http://xircles.codehaus.org/manage_email
>  >>>>
>  >>>>
>  >>>>
>  >>>
>  >>> --------------------------------------------------------------------
>  >>> -
>  >>> To unsubscribe from this list, please visit:
>  >>>
>  >>>    http://xircles.codehaus.org/manage_email
>  >>>
>  >>>
>  >>
>  >>
>  >>
>  >> ---------------------------------------------------------------------
>  >>  To unsubscribe from this list, please visit:
>  >>
>  >>     http://xircles.codehaus.org/manage_email
>  >>
>  >>
>  >>
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe from this list, please visit:
>  >
>  >     http://xircles.codehaus.org/manage_email
>  >
>  >
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Dynamically adding to classpath