[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Importing and Using User Defined Classes



On Wed, Jan 26, 2000 at 01:53:01PM -0600, Chuck Irvine wrote:
> 
> 1. I couldn't get the BeanShell that came with the latest jde beta
> distribution to work, so I downloaded it from
> http://www.beanshell.org/bsh-1.0.jar. 

What version is the one that came with the JDE?  
(It should print the version when it starts up).

> 2. Then I moved bsh to the directory that has the attached file in it.
> Shouldn't have to probably, but I was grasping at straws.
> 
> 3. Then double click in bsh-1.0.jar to invoke the BeanShell desktop.

Well, if you start bsh by double clicking the jar file then Java probably 
doesn't have the class path set to include the current directory.

If you could try running bsh from the command line:

  java -classpath bsh-1.0.jar;. bsh.Console

that would include both the jar file and the current directory in the path.

I'm going to try to make bsh friendlier about loading classes not in the class
path in the next release.


> 4. Entered at the bsh prompt, taking you advice to not invoke "Impot": 
>     >  Foo foo = new Foo();
> This triggers the bsh error:
> // Error: bsh.EvalError: "Foo" does not resolve to a class name.  It is
> undefined. : 
> 
> 5. Next I try import and then step # 4 again:
>    > import Foo;
>    > Foo foo = new Foo();  --- Still hangs here

Yes, I see.  I just tried it and it does hang.

I'll investigate why.

In general you should be able to use any class in the class path without
explicitly importing it.  e.g.:

  new Foo()
  new mypackage.Foo();

So I think you're stubmling over two problems 1) not having Foo in the
classpath and 2) a bug that you've discovered involving importing explicit
class names.

(sorry ;) )


Pat