NameError: class not found in packages


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”);


Have you add the selenium jar to the classpath too?

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


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.