> Using a bash shell script such as:
>
> CLASSPATH=foo.jar:build/:lib/
> export CLASSPATH
> java -jar jruby.jar myruby.rb
A classic java gotcha!
From the java man page section on -jar:
"When you use this option, the JAR file is the source of all user
classes, and other user class path settings are ignored."
So either 1) don't use -jar or 2) require 'my.jar'.
Damian
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
On Tue, Jun 24, 2008 at 1:09 AM, Johnny P <jpyw...@gmail.com> wrote:
> Thanks Damian. I ended up just putting the jruby jar in the -classpath on
> the command line then I used org.jruby.Main as the main class. That worked.
>
> Dennis setting/changing the CLASSPATH const does not work. For example
>
> # myruby.rb
> CLASSPATH="spring.jar"
> import org.springframework.context.support.ClassPathXmlApplicationContext;
The code should be a bit different, you should use $CLASSPATH global variable,
it is an array, and you need to add your JAR files there:
$CLASSPATH << "ant.jar"
import org.apache.tools.ant.AntClassLoader
This works wine for me.
Thanks,
--Vladimir
Hi Johnny,
I think this Jira bug report I entered about 6 weeks ago might describe the underlying cause for the problem you are having.
http://jira.codehaus.org/browse/JRUBY-2495
Requiring and using a Java library that ends up using a Thread Context classloader doesn't work.
I included a simplified test case but have had no comments yet from anybody.
On Wed, Jun 25, 2008 at 3:20 AM, Stephen Bannasch
> I think this Jira bug report I entered about 6 weeks ago might describe the underlying cause for the problem you are having.
>
> http://jira.codehaus.org/browse/JRUBY-2495
> Requiring and using a Java library that ends up using a Thread Context classloader doesn't work.
Yes, that's the same issue. Also, I've encountered another case when
proper thread context classloader is required: loading JDBC drivers
that are not on CLASSPATH.
Luckily, there is a more or less straightforward way to adjust the
context classloader:
require 'jruby'
java.lang.Thread.currentThread.setContextClassLoader(JRuby.runtime.jruby_class_loader)
With that, I verified that the test case from the bug report pass. And
JDBC drivers are loaded OK too.