Forum: JRuby NameError: class not found in packages

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
4edfcc6443904cbc2060a167a40e1b2a?d=identicon&s=25 Arthur K. (arthur21)
on 2015-03-31 21:33

I appreciate if somebody will help me to understand and resolve the
problem I have.

I have in file the following class and while I create a
class object in a Ruby file it gets into an error if I have not
commented the instantiating of 'webDriver' ( see below ).
With the commented 'webDriver' I can call func1() and func2() Java
methods from Ruby code ( jruby test.rb ===> calling Java methods from
test.rb )

Please note that Java compilation passes with no errors and I create
then put the classes JAR file in $CLASSPATH in my Ruby file ( $CLASSPATH
<< "the_classes_jar_file" )

Without commented the 'webDriver' I am getting the following error:


: NameError: BaseClass not found in packages p1; last error: cannot link
Java class p1.BaseClass,probable missing dependency:


Here is the class:

package p1;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.*;

public class BaseClass
  protected static WebDriver webDriver  = null;

    public void configureParameters( String firefoxProfileDir )
       this.firefoxProfileDir = firefoxProfileDir; profilefile = new File(this.firefoxProfileDir);
       FirefoxProfile profile = new FirefoxProfile(profilefile);
 //    webDriver = new FirefoxDriver(profile);

   public void func1()
      System.out.println("calling func1 from BaseClass");

   public void func2()
      System.out.println("calling func2 from BaseClass");
Kimpton, C (Chris) (Guest)
on 2015-04-01 08:26
(Received via mailing list)

Have you add the selenium jar to the classpath too?

You can change the classpath from within Jruby - didn't realise that was
possible.  :)

4edfcc6443904cbc2060a167a40e1b2a?d=identicon&s=25 Arthur K. (arthur21)
on 2015-04-01 09:15
Yes, I have added selenium jar file as a 'javac' command argument (javac
-cp "G:\selenium_web_driver\*; ... ).

And here is what I have for setting the class path in a Ruby code ( this
is on top of the Ruby script, right after 'require'  )
 $CLASSPATH << 'G:/thePaths/myclasses.jar'

This is a linking issue in Jruby ( probably a bug in Jruby ), cause the
same code works while I build and run from Eclipse.
This topic is locked and can not be replied to.